Useful
Inventions
Favorite
Quotes
Game
Design
Atari
Memories
Personal
Pages

bB Playfield Editor

Draw DPC+ and standard kernel Atari 2600 playfields.

As an Amazon Associate I earn from qualifying purchases.

 
 
 

 

 

 

About the bB Playfield Editor

The playfield editor above is a JavaScript tool for batari Basic users (made with SpiderBasic). It's based on the Atari Background Builder by kisrael. I wanted more DPC+ row options, so I tried to make my own less advanced version using SpiderBasic. The helpful people at the SpiderBasic forums ended up doing most of the work since I know very little about PureBasic, SpiderBasic, or JavaScript.

 

 

 

 

Download DPCplus.arm

DPC+ 176 rows and DPC+ 88 rows will not display properly in Stella or a real Atari 2600 without tricks developed by Lillapojkenpåön at AtariAge. Problem is that a DPC+ driver update made a change that caused the tricks to stop working using Stella 6.0 through 6.5.3 and the Harmony cart. Thanks to SpiceWare, if you go to AtariAge, download DPCplus.arm, and put it in your batari Basic includes folder, the tricks will work again using the latest version of Stella and the Harmony cart:

 

Download DPCplus.arm from AtariAge

 

The code that the bB Playfield Editor generates uses Lillapojkenpåön's tricks to make DPC+ 176 and DPC+ 88 screens display properly, so be sure to download that file and put it in your bB includes folder.

 

 

 

 

Playfield Canvas

The big rectangle on the left side of the gray area is the playfield canvas. That's where you can draw playfield pixels and paint colors. Hold down the left mouse button to draw (with the Draw button selected). You can erase by left clicking on the Erase button or by holding down the Ctrl key while drawing.

 

 

 

 

Row Mode

There are DPC+, standard kernel, and multisprite kernel modes. You have 5 DPC+ choices (176 rows, 88 rows, 44 rows, 22 rows, and 11 rows). There are 2 standard kernel choices (11 rows with blank lines and 11 rows with no_blank_lines). There are also 3 multisprite kernel choices (44 rows, 22 rows, and 11 rows). All modes have 32 columns.

 

If you select standard kernel no_blank_lines 11 rows, each playfield pixel will have a thin layer of color on top from the row above it (like icing on a cake). This happens because the graphics data for the next line is loaded and stored before the color data for the next line, so the color of the previous line carries over at the top of the new line. It might be undesirable for some games, but you can use the ‘icing’ to your advantage and have a high-resolution look with thin lines for various types of games.

 

Warning: Changing modes clears the playfield canvas, so don't change modes unless you are sure you want to delete everything.

 

 

 

 

Buttons and Boxes

Below are descriptions of the buttons and boxes.

 

 

 

Draw Button

Left click the Draw button when you want to draw playfield pixels on the playfield canvas. Hold down the left Ctrl key while drawing to quickly erase.

 

 

 

Erase Button

Left click the Erase button if you'd like to do nothing but erase playfield pixels on the playfield canvas. You don't have to waste time clicking on the Erase button every time you want to erase while drawing. You can hold down the left Ctrl key while drawing and erase that way. It's much faster than moving the mouse pointer all the way over to the Erase button.

 

 

 

Paint FG Row Button

Lets you paint any foreground row on the playfield canvas. Just left click on a row to paint using the current foreground color. The bar on the left side of the playfield canvas area will display foreground row colors.

 

 

 

Paint BG Row Button

Allows you to paint any background row on the playfield canvas. Just left click on a row to paint using the current background color.

 

If you're using one of the standard kernel row modes, the entire background will be changed to the current background color.

 

 

 

Foreground Color Box

Displays the current foreground color. Left clicking on the box makes an NTSC color chart pop up where you can select a new foreground color. Once you select a new color, the Paint FG Row button will be automatically selected so you can paint a foreground row right away without being slowed down by an extra button click.

 

If you bring up the NTSC chart and decide not to select a color, just move the mouse pointer outside of the pop-up window area and the window will close.

 

 

 

Background Color Box

Displays the current background color. Left clicking on the box makes an NTSC color chart pop up where you can select a new background color. Once you select a new color, the Paint BG Row button will be automatically selected so you can paint a background row right away without being slowed down by an extra button click.

 

If you bring up the NTSC chart and decide not to select a color, just move the mouse pointer outside of the pop-up window area and the window will close.

 

 

 

Clear Button

Left click this button to clear the playfield canvas.

 

Warning: Clearing the playfield canvas cannot be undone. Use at your own risk.

 

 

 

Generate bB Code

Left click this button and a window will open with code in it that is ready to be compiled and run. Left clicking on the code will highlight all of it. Just use Ctrl + c on your keyboard to copy it, then paste it into the editor you use to compile bB programs. Compile the program and run it in your favorite emulator. Most people use Stella.

 

I usually have a blank test file open in Visual batari Basic so I can paste code into it and compile and run it.

 

 

 

 

SpiderBasic Code

Below is the latest SpiderBasic code for the bB Playfield Editor. If you have any ideas on how to improve it, please let me know. For example, I'd like to add buttons such as line, rectangle, elipse, text, select/copy/paste, and undo/redo.

 

;***********************************************************************
;***********************************************************************
;
;- BUG CATCHER
;
;  When explicit mode is enabled, all the variables which are not
;  explicitly declared with Define, Global, Protected or Static are
;  not accepted and the compiler will raise an error. It can help to
;  catch typo bugs.
;
EnableExplicit



;***********************************************************************
;***********************************************************************
;
;- APP NAME AND VERSION
;
#AppName = "bB Playfield Editor"
#Version = "2021y_08m_17d_0744t"



;***********************************************************************
;***********************************************************************
;
;- CONSTANTS
;
;  Important for better code readability. The first constant found in
;  the enumeration will get the number 0 and the next one will be 1 etc.
;  (The # at the beginning lets you know it's a constant.)
;
Enumeration windows
#Window_Main  
#Window_NTSC_Color_Chart
#Window_Code
#bB_Code_Window
EndEnumeration

Enumeration gadgets
#Button_Clear
#Button_Generate_Code
#Foreground_Color_Box
#Background_Color_Box
#Button_Draw
#Button_Erase
#Button_Paint_FG_Row
#Button_Paint_BG_Row
#Canvas_Playfield
#Row_Mode_Dropdown_Menu
#NTSC_Gadget
#bB_Gadget
#Text_for_Editing_Mode
#Text_for_Foreground_Color
#Text_for_Background_Color
#Text_for_Footer
#Text_for_Row_Mode
EndEnumeration

Enumeration fonts
#Font_UiBig
#Font_UiNormal
#Font_UiSmall
EndEnumeration



;***********************************************************************
;***********************************************************************
;
;- GLOBAL
;
;  Fixes it so variables can be used everywhere in the program.
;
;  Each variable may have a default value directly assigned to it.
;  Global may also be used with arrays, lists, and maps.
;
;```````````````````````````````````````````````````````````````````````
;  User Interface
;
Global bB_CodeTable.s
Global colorWindowBG = $A7A7A7         ; Background color of the whole window.
Global _Text_Color = $000000           ; Text Color
Global fontUiBig.s = "Arial"           ; fonts for text in editor ui 
Global fontUiBigSize = 30
Global fontUiNormal.s = "Arial"
Global fontUiNormalSize = 16
Global fontUiSmall.s = "Arial"
Global fontUiSmallSize = 12
Global _Spacer = 10                     ; space between ui elements; change as you like
Global textFooter.s = #AppName + "  -  Version: " + #Version + " by <a class='offsite' href='https://www.randomterrain.com/'>randomterrain.com</a> (using SpiderBasic)." + "<br /><br />Based on the <a class='offsite' href='https://alienbill.com/2600/atari-background-builder/'>Atari Background Builder</a> by kisrael.<br /><br />Program by <a class='offsite' href='https://forums.spiderbasic.com/viewtopic.php?p=8135#p8135'>munfraid</a> with NTSC color data help by <a class='offsite' href='https://forums.spiderbasic.com/viewtopic.php?p=8120#p8120'>Peter</a> and additional help from <a class='offsite' href='https://forums.spiderbasic.com/viewtopic.php?p=8189#p8189'>Paul</a>. Program adapted by Random Terrain (Duane Alan Hahn).<br /><br />"
;
;```````````````````````````````````````````````````````````````````````
;  Playfield
;
Global _Button_Mode = #Button_Draw   ; Default button mode.
Global colorFG = #Black              ; Default foreground color.
Global colorBG = $E9EAEA             ; Default background color.
Global _32_Columns = 33              ; Fixed value for number of columns.
Global _Column_Scale = 15            ; Currently set to 15, which results in 15*32 columns = 480 pixel width; change as you wish.
Global _176_Rows = 176               ; Fixed value for maximum number of rows.
Global _Row_Scale = 2                ; Similar to _Column_Scale. It's the base height of a row.
Global _Row_Height = 2               ; Set to 2 by default because I put 88 rows as default in the initUI() procedure.
Global x, y, yy, xx                  ; The x and y coordinates of the mouse pointer when drawing on the canvas.
Global GID                           ; Gadjet ID.
Global _Which_Color_FG_or_BG         ; Keeps track of which FG/BG color box was clicked.
Global _Loop                         ; Used for loops.
Global _Atari_Counter                ; A counter used when creating the NTSC color chart.
Global _EnableDrawing = #False       ; Fixes problem where user could draw without holding down mouse button.
Global _Current_FG.s                 ; Current foreground Atari color.
Global _Current_BG.s                 ; Current background Atari color.
Global _bB_Rows = 87                 ; Default rows for the bB arrays.
Global _Row                          ; Used for loops.
Global _Column                       ; Used for loops.
Global _Ctrl_Key_Memory = 0          ; Keeps track of the control key.
Global _Row_Start = 8                ; Limits drawing.
Global _Row_Limit = 95               ; Limits drawing.
Global _Drop_Down                    ; Drop down check for row mode.
Global _Other_Kernels = 0            ; Tells program when another kernel has been selected.
Global _SK_with_blank_lines = 1      ; Standard kernel with blank lines (11 rows and 1 background color).
Global _SK_no_blank_lines = 2        ; Standard kernel no_blank_lines (11 rows and 1 background color).
Global _Multisprite = 3              ; Multisprite kernel (only 1 foreground color and 1 background color).

;```````````````````````````````````````````````````````````````````````
;  Arrays.
;
Global Dim _Playfield_Pixels(40, 220)
Global Dim _Playfield_Foreground_Colors(220)
Global Dim _Playfield_Background_Colors(220)
Global Dim _bB_playfield.s(32, 88)
Global Dim _bB_pfcolors.s(88)
Global Dim _bB_bkcolors.s(88)




;***********************************************************************
;***********************************************************************
;
;- PROCEDURES START HERE
;  (Similar To subroutines in older BASIC languages.)
;
;***********************************************************************
;***********************************************************************




;***********************************************************************
;***********************************************************************
;
;- CLEAR PLAYFIELD
;
Procedure ClearPlayfield()

Protected _Column
Protected _Row

;```````````````````````````````````````````````````````````````````````
;  Clears the canvas arrays.
;
Global Dim _Playfield_Pixels(40, 220)
Global Dim _Playfield_Foreground_Colors(220)
Global Dim _Playfield_Background_Colors(220)

;```````````````````````````````````````````````````````````````````````
;  Puts boxes down left side.
;
For _Loop = 0 To 220
_Playfield_Pixels(0, _Loop)
Next

;```````````````````````````````````````````````````````````````````````
;  Clears the playfield canvas.
;
StartDrawing(CanvasOutput(#Canvas_Playfield))
Box(0, 0, 551, 417, $E9EAEA)
StopDrawing()

;```````````````````````````````````````````````````````````````````````
;  Sets default colors.
;
colorFG = #Black
colorBG = $E9EAEA

;```````````````````````````````````````````````````````````````````````
;  Restores the foreground color box to the default.
;  (Includes inline JavaScript magic.)
;
GID=GadgetID(#Foreground_Color_Box)
! $(v_gid.div).find(".dijitButtonContents").css("background-color", spider_helper_ColorToHtml(v_colorfg));

;```````````````````````````````````````````````````````````````````````
;  Restores the background color box to the default.
;  (Includes inline JavaScript magic.)
;
GID=GadgetID(#Background_Color_Box)
! $(v_gid.div).find(".dijitButtonContents").css("background-color", spider_helper_ColorToHtml(v_colorbg));

;```````````````````````````````````````````````````````````````````````
;  Clears the foreground and background color arrays.
;
For _Loop = 0 To _176_Rows
_Playfield_Foreground_Colors(_Loop) = colorFG
_Playfield_Background_Colors(_Loop) = colorBG
Next

;```````````````````````````````````````````````````````````````````````
;  Removes any checkmarks from buttons.
;
For _Loop = #Button_Draw To #Button_Paint_BG_Row
SetGadgetState(_Loop, 0)
Next

;```````````````````````````````````````````````````````````````````````
;  Puts a check mark on the Draw button and sets mode to Draw.
;
SetGadgetState(#Button_Draw, 1)
_Button_Mode = #Button_Draw

;```````````````````````````````````````````````````````````````````````
;  Fills the bB playfield array with dots.
;
For _Row = 0 To _bB_Rows
For _Column = 0 To 31
_bB_playfield(_Column, _Row) = "."
Next
Next

;```````````````````````````````````````````````````````````````````````
;  bB color row preparation.
;
yy = _bB_Rows
If _Row_Height = 1 ; If 176 rows, there can only be 88 rows of color.
yy = 87
EndIf

;```````````````````````````````````````````````````````````````````````
;  Fills the bB pfcolors array with black.
;
For _Row = 0 To yy
_bB_pfcolors(_Row) = "$00"
Next

;```````````````````````````````````````````````````````````````````````
;  Fills the bB bkcolors array with white.
;
For _Row = 0 To yy
_bB_bkcolors(_Row) = "$0E"
Next

;```````````````````````````````````````````````````````````````````````
;  Creates black box around playfield area.
;
StartDrawing(CanvasOutput(#Canvas_Playfield))
Box(28, 30, 484, 356, #White)
Box(29, 31, 481.5, 354, #Black)
Box(30, 32, 480, 352, $E9EAEA)
StopDrawing()

;```````````````````````````````````````````````````````````````````````
;  Draws black line down left side.
;
Box(0, 32, 9, 352, #Black)

EndProcedure




;***********************************************************************
;***********************************************************************
;
;- TIMER EVENTS
;
Procedure TimerEvents()

Select EventTimer()

;```````````````````````````````````````````````````````````````````````
;  Makes NTSC color chart disappear if mouse pointer leaves area.
;
Case 0
If WindowMouseX(#Window_NTSC_Color_Chart) = -1
CloseWindow(#Window_NTSC_Color_Chart)  
EndIf

EndSelect

EndProcedure




;***********************************************************************
;***********************************************************************
;
;- WINDOW EVENTS
;
Procedure WindowEvents()

Select EventWindow()

Case #Window_NTSC_Color_Chart
CloseWindow(#Window_NTSC_Color_Chart)

EndSelect  

EndProcedure




;***********************************************************************
;***********************************************************************
;
;- CLOSES WINDOWS WHEN CLOSE BUTTON IS CLICKED
;
Procedure CloseWindowEvent()

CloseWindow(EventWindow())

EndProcedure




;***********************************************************************
;***********************************************************************
;
;- FOREGROUND/BACKGROUND COLOR SELECTION FOR ROW PAINTING
;
Procedure ColorCellClicked(Title.s, Color.s)

;```````````````````````````````````````````````````````````````````````
;  Replaces the six-digit color code hash sign with a dollar sign.
;
Protected _Selected_Color = Val(ReplaceString(Color.s, "#", "$"))

;```````````````````````````````````````````````````````````````````````
;  When using six-digit color codes with SpiderBasic, the red and blue
;  parts must be swapped (BGR format instead of RGB), so the first two
;  numbers must be switched with the last two numbers. The code below
;  does that automatically.
;
_Selected_Color = Blue(_Selected_Color) + Green(_Selected_Color)*256 + Red(_Selected_Color)*65536 


;***********************************************************************
;
;  Foreground/Background color box click check.
;
Select _Which_Color_FG_or_BG

;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;  Foreground color box check. (Brings up NTSC chart if clicked).
;
Case #Foreground_Color_Box
colorFG = _Selected_Color

;```````````````````````````````````````````````````````````````````````
;  Clears buttons and selects Paint FG button.
For _Loop = #Button_Draw To #Button_Paint_BG_Row
SetGadgetState(_Loop, 0)
Next

;```````````````````````````````````````````````````````````````````````
;  Puts a check mark on the Paint FG button and sets mode to Paint FG.
SetGadgetState(#Button_Paint_FG_Row, 1)
_Button_Mode = #Button_Paint_FG_Row

;```````````````````````````````````````````````````````````````````````
;  Changes the foreground color box to the chosen color.
;  (Includes inline JavaScript magic.)
GID=GadgetID(#Foreground_Color_Box)
! $(v_gid.div).find(".dijitButtonContents").css("background-color", spider_helper_ColorToHtml(v_colorfg));

;```````````````````````````````````````````````````````````````````````
;  Remembers Atari 2600 color string.
_Current_FG = Title

;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;  Background color box check. (Brings up NTSC chart if clicked).
;
Case #Background_Color_Box
colorBG = _Selected_Color

;```````````````````````````````````````````````````````````````````````
;  Clears buttons and selects Paint BG button.
For _Loop = #Button_Draw To #Button_Paint_BG_Row
SetGadgetState(_Loop, 0)
Next

;```````````````````````````````````````````````````````````````````````
;  Puts a check mark on the Paint BG button and sets mode to Paint BG.
SetGadgetState(#Button_Paint_BG_Row, 1)
_Button_Mode = #Button_Paint_BG_Row

;```````````````````````````````````````````````````````````````````````
;  Changes the background color box to the chosen color.
;  (Includes inline JavaScript magic.)
GID=GadgetID(#Background_Color_Box)
! $(v_gid.div).find(".dijitButtonContents").css("background-color", spider_helper_ColorToHtml(v_colorbg));

;```````````````````````````````````````````````````````````````````````
;  Remembers Atari 2600 color string.
_Current_BG = Title

EndSelect

;```````````````````````````````````````````````````````````````````````
;  Closes the NTSC color chart window.
;
CloseWindow(#Window_NTSC_Color_Chart)

EndProcedure




;***********************************************************************
;***********************************************************************
;
;- bB CODE OUTPUT
;
;  (The .s stands for STRING.)
;
Procedure.s bB_Procedure()


Protected bBCode.s

bBCode + "<pre><br>"

If _Other_Kernels = _SK_with_blank_lines
bBCode + "   ;****************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Standard kernel options.<br>"
bBCode + "   ;<br>"
bBCode + "   set kernel_options pfcolors<br><br><br>"
EndIf

If _Other_Kernels = _SK_no_blank_lines
bBCode + "   ;****************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Standard kernel options. Cost: loss of missile0.<br>"
bBCode + "   ;<br>"
bBCode + "   set kernel_options pfcolors no_blank_lines<br><br><br>"
EndIf

If _Other_Kernels = _Multisprite
bBCode + "   ;****************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Multisprite kernel.<br>"
bBCode + "   ;<br>"
bBCode + "   set kernel multisprite<br><br><br>"
EndIf

If _Other_Kernels = _Multisprite And _bB_Rows = 43
bBCode + "   ;****************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Sets 44 rows for multisprite kernel.<br>"
bBCode + "   ;<br>"
bBCode + "   pfheight = 1<br><br><br>"
EndIf

If _Other_Kernels = _Multisprite And _bB_Rows = 21
bBCode + "   ;****************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Sets 22 rows for multisprite kernel.<br>"
bBCode + "   ;<br>"
bBCode + "   pfheight = 3<br><br><br>"
EndIf

If _Other_Kernels = _Multisprite And _bB_Rows = 10
bBCode + "   ;****************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Sets 11 rows for multisprite kernel.<br>"
bBCode + "   ;<br>"
bBCode + "   pfheight = 7<br><br><br>"
EndIf

If _Other_Kernels = 0
bBCode + "   ;****************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  This program uses the DPC+ kernel.<br>"
bBCode + "   ;<br>"
bBCode + "   set kernel DPC+<br><br><br>"
EndIf

bBCode + "   ;****************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Standard used in North America and most of South America.<br>"
bBCode + "   ;<br>"
bBCode + "   set tv ntsc<br><br><br>"

bBCode + "   ;****************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  NTSC colors.<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Use these constants so you can quickly and easily swap them<br>"
bBCode + "   ;  out for PAL-60 colors. Or use this if you created a PAL-60<br>"
bBCode + "   ;  game and want to instantly convert the colors to NTSC (if you<br>"
bBCode + "   ;  were already using the PAL-60 constants).<br>"
bBCode + "   ;<br>"
bBCode + "   const _00 = $00<br>"
bBCode + "   const _02 = $02<br>"
bBCode + "   const _04 = $04<br>"
bBCode + "   const _06 = $06<br>"
bBCode + "   const _08 = $08<br>"
bBCode + "   const _0A = $0A<br>"
bBCode + "   const _0C = $0C<br>"
bBCode + "   const _0E = $0E<br>"
bBCode + "   const _10 = $10<br>"
bBCode + "   const _12 = $12<br>"
bBCode + "   const _14 = $14<br>"
bBCode + "   const _16 = $16<br>"
bBCode + "   const _18 = $18<br>"
bBCode + "   const _1A = $1A<br>"
bBCode + "   const _1C = $1C<br>"
bBCode + "   const _1E = $1E<br>"
bBCode + "   const _20 = $20<br>"
bBCode + "   const _22 = $22<br>"
bBCode + "   const _24 = $24<br>"
bBCode + "   const _26 = $26<br>"
bBCode + "   const _28 = $28<br>"
bBCode + "   const _2A = $2A<br>"
bBCode + "   const _2C = $2C<br>"
bBCode + "   const _2E = $2E<br>"
bBCode + "   const _30 = $30<br>"
bBCode + "   const _32 = $32<br>"
bBCode + "   const _34 = $34<br>"
bBCode + "   const _36 = $36<br>"
bBCode + "   const _38 = $38<br>"
bBCode + "   const _3A = $3A<br>"
bBCode + "   const _3C = $3C<br>"
bBCode + "   const _3E = $3E<br>"
bBCode + "   const _40 = $40<br>"
bBCode + "   const _42 = $42<br>"
bBCode + "   const _44 = $44<br>"
bBCode + "   const _46 = $46<br>"
bBCode + "   const _48 = $48<br>"
bBCode + "   const _4A = $4A<br>"
bBCode + "   const _4C = $4C<br>"
bBCode + "   const _4E = $4E<br>"
bBCode + "   const _50 = $50<br>"
bBCode + "   const _52 = $52<br>"
bBCode + "   const _54 = $54<br>"
bBCode + "   const _56 = $56<br>"
bBCode + "   const _58 = $58<br>"
bBCode + "   const _5A = $5A<br>"
bBCode + "   const _5C = $5C<br>"
bBCode + "   const _5E = $5E<br>"
bBCode + "   const _60 = $60<br>"
bBCode + "   const _62 = $62<br>"
bBCode + "   const _64 = $64<br>"
bBCode + "   const _66 = $66<br>"
bBCode + "   const _68 = $68<br>"
bBCode + "   const _6A = $6A<br>"
bBCode + "   const _6C = $6C<br>"
bBCode + "   const _6E = $6E<br>"
bBCode + "   const _70 = $70<br>"
bBCode + "   const _72 = $72<br>"
bBCode + "   const _74 = $74<br>"
bBCode + "   const _76 = $76<br>"
bBCode + "   const _78 = $78<br>"
bBCode + "   const _7A = $7A<br>"
bBCode + "   const _7C = $7C<br>"
bBCode + "   const _7E = $7E<br>"
bBCode + "   const _80 = $80<br>"
bBCode + "   const _82 = $82<br>"
bBCode + "   const _84 = $84<br>"
bBCode + "   const _86 = $86<br>"
bBCode + "   const _88 = $88<br>"
bBCode + "   const _8A = $8A<br>"
bBCode + "   const _8C = $8C<br>"
bBCode + "   const _8E = $8E<br>"
bBCode + "   const _90 = $90<br>"
bBCode + "   const _92 = $92<br>"
bBCode + "   const _94 = $94<br>"
bBCode + "   const _96 = $96<br>"
bBCode + "   const _98 = $98<br>"
bBCode + "   const _9A = $9A<br>"
bBCode + "   const _9C = $9C<br>"
bBCode + "   const _9E = $9E<br>"
bBCode + "   const _A0 = $A0<br>"
bBCode + "   const _A2 = $A2<br>"
bBCode + "   const _A4 = $A4<br>"
bBCode + "   const _A6 = $A6<br>"
bBCode + "   const _A8 = $A8<br>"
bBCode + "   const _AA = $AA<br>"
bBCode + "   const _AC = $AC<br>"
bBCode + "   const _AE = $AE<br>"
bBCode + "   const _B0 = $B0<br>"
bBCode + "   const _B2 = $B2<br>"
bBCode + "   const _B4 = $B4<br>"
bBCode + "   const _B6 = $B6<br>"
bBCode + "   const _B8 = $B8<br>"
bBCode + "   const _BA = $BA<br>"
bBCode + "   const _BC = $BC<br>"
bBCode + "   const _BE = $BE<br>"
bBCode + "   const _C0 = $C0<br>"
bBCode + "   const _C2 = $C2<br>"
bBCode + "   const _C4 = $C4<br>"
bBCode + "   const _C6 = $C6<br>"
bBCode + "   const _C8 = $C8<br>"
bBCode + "   const _CA = $CA<br>"
bBCode + "   const _CC = $CC<br>"
bBCode + "   const _CE = $CE<br>"
bBCode + "   const _D0 = $D0<br>"
bBCode + "   const _D2 = $D2<br>"
bBCode + "   const _D4 = $D4<br>"
bBCode + "   const _D6 = $D6<br>"
bBCode + "   const _D8 = $D8<br>"
bBCode + "   const _DA = $DA<br>"
bBCode + "   const _DC = $DC<br>"
bBCode + "   const _DE = $DE<br>"
bBCode + "   const _E0 = $E0<br>"
bBCode + "   const _E2 = $E2<br>"
bBCode + "   const _E4 = $E4<br>"
bBCode + "   const _E6 = $E6<br>"
bBCode + "   const _E8 = $E8<br>"
bBCode + "   const _EA = $EA<br>"
bBCode + "   const _EC = $EC<br>"
bBCode + "   const _EE = $EE<br>"
bBCode + "   const _F0 = $F0<br>"
bBCode + "   const _F2 = $F2<br>"
bBCode + "   const _F4 = $F4<br>"
bBCode + "   const _F6 = $F6<br>"
bBCode + "   const _F8 = $F8<br>"
bBCode + "   const _FA = $FA<br>"
bBCode + "   const _FC = $FC<br>"
bBCode + "   const _FE = $FE<br><br><br>"

If _Other_Kernels = 0
bBCode + "   goto __Bank_2 bank2<br><br><br>"

bBCode + "   bank 2<br>"
bBCode + "   temp1=temp1<br><br><br>"

bBCode + "__Bank_2<br><br><br>"
EndIf

;```````````````````````````````````````````````````````````````````````
;  bB PF pixel preparation.
;
yy = 31
If _Other_Kernels = _Multisprite ; Cuts column number in half if multisprite.
yy = 15
EndIf

;```````````````````````````````````````````````````````````````````````
;  bB playfield data.
;
bBCode + "   playfield:<br>"
For _Row = 0 To _bB_Rows

bBCode + "   "

For _Column = 0 To yy

bBCode + _bB_playfield(_Column, _Row)

Next
bBCode + "<br>"

Next

bBCode + "end<br><br><br>"

If _Other_Kernels = 0

;```````````````````````````````````````````````````````````````````````
;  bB color row preparation.
;
yy = _bB_Rows
If _Row_Height = 1 ; If 176 rows, there can only be 88 rows of color.
yy = 87
EndIf

;```````````````````````````````````````````````````````````````````````
;  bB foreground color data.
;
bBCode + "   pfcolors:<br>"

For _Row = 0 To yy

bBCode + "   " + ReplaceString(_bB_pfcolors(_Row), "$", "_") + "<br>"

Next

bBCode + "end<br><br><br>"

;```````````````````````````````````````````````````````````````````````
;  bB background color data.
;
bBCode + "   bkcolors:<br>"

For _Row = 0 To yy

bBCode + "   " + ReplaceString(_bB_bkcolors(_Row), "$", "_") + "<br>"

Next

bBCode + "end"

EndIf

If _Other_Kernels > 0

bBCode + "   COLUBK = " + ReplaceString(_bB_bkcolors(0), "$", "_") + "<br>"

EndIf


If _Other_Kernels = _Multisprite

bBCode + "<br>" + "   COLUPF = " + ReplaceString(_bB_pfcolors(0), "$", "_") + "<br>"

EndIf


bBCode + "<br><br><br>"

;```````````````````````````````````````````````````````````````````````
;  Main Loop code.
;
bBCode + "__Main_Loop"

bBCode + "<br><br><br>"


If _Other_Kernels = _SK_with_blank_lines Or _Other_Kernels = _SK_no_blank_lines
;```````````````````````````````````````````````````````````````````````
;  bB foreground color data for standard kernel.
;
bBCode + "   pfcolors:<br>"

If _Other_Kernels = _SK_no_blank_lines
bBCode + "   " + ReplaceString(_bB_pfcolors(0), "$", "_") + "<br>"
EndIf

For _Row = 0 To _bB_Rows

bBCode + "   " + ReplaceString(_bB_pfcolors(_Row), "$", "_") + "<br>"

Next

If _Other_Kernels = _SK_with_blank_lines
bBCode + "   " + ReplaceString(_bB_pfcolors(_bB_Rows), "$", "_") + "<br>"
EndIf

bBCode + "end<br>"
EndIf

If _Other_Kernels = 0

bBCode + "   ;***************************************************************<br>"
bBCode + "   ;<br>"

;```````````````````````````````````````````````````````````````````````
;  DFxFRACINC based on number of rows.
;
Select _bB_Rows

Case 175
bBCode + "   ;  176 rows that are 1 scanline high. (88 rows of color).<br>"
bBCode + "   ;<br>"
bBCode + "   DF6FRACINC = 255 ; Background colors.<br>"
bBCode + "   DF4FRACINC = 255 ; Playfield colors.<br><br>"
bBCode + "   DF0FRACINC = 255 ; Column 0.<br>"
bBCode + "   DF1FRACINC = 255 ; Column 1.<br>"
bBCode + "   DF2FRACINC = 255 ; Column 2.<br>"
bBCode + "   DF3FRACINC = 255 ; Column 3.<br><br><br><br>"

bBCode + "   ;***************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Simple fix for the top and bottom rows.<br>"
bBCode + "   ;<br>"
bBCode + "   asm<br>"
bBCode + "   lda DF6FRACDATA<br>"
bBCode + "   lda DF4FRACDATA<br>"
bBCode + "   lda DF0FRACDATA<br>"
bBCode + "   lda DF1FRACDATA<br>"
bBCode + "   lda DF2FRACDATA<br>"
bBCode + "   lda DF3FRACDATA<br>"
bBCode + "end<br>"

Case 87
bBCode + "   ;  88 rows that are 2 scanlines high.<br>"
bBCode + "   ;<br>"
bBCode + "   DF6FRACINC = 255 ; Background colors.<br>"
bBCode + "   DF4FRACINC = 255 ; Playfield colors.<br><br>"
bBCode + "   DF0FRACINC = 128 ; Column 0.<br>"
bBCode + "   DF1FRACINC = 128 ; Column 1.<br>"
bBCode + "   DF2FRACINC = 128 ; Column 2.<br>"
bBCode + "   DF3FRACINC = 128 ; Column 3.<br><br><br><br>"

bBCode + "   ;***************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Simple fix for the top two lines having the same color.<br>"
bBCode + "   ;<br>"
bBCode + "   asm<br>"
bBCode + "   lda DF6FRACDATA<br>"
bBCode + "   lda DF4FRACDATA<br>"
bBCode + "end<br>"

Case 43
bBCode + "   ;  44 rows that are 4 scanlines high.<br>"
bBCode + "   ;<br>"
bBCode + "   DF6FRACINC = 128 ; Background colors.<br>"
bBCode + "   DF4FRACINC = 128 ; Playfield colors.<br><br>"
bBCode + "   DF0FRACINC = 64 ; Column 0.<br>"
bBCode + "   DF1FRACINC = 64 ; Column 1.<br>"
bBCode + "   DF2FRACINC = 64 ; Column 2.<br>"
bBCode + "   DF3FRACINC = 64 ; Column 3.<br>"

Case 21
bBCode + "   ;  22 rows that are 8 scanlines high.<br>"
bBCode + "   ;<br>"
bBCode + "   DF6FRACINC = 64 ; Background colors.<br>"
bBCode + "   DF4FRACINC = 64 ; Playfield colors.<br><br>"
bBCode + "   DF0FRACINC = 32 ; Column 0.<br>"
bBCode + "   DF1FRACINC = 32 ; Column 1.<br>"
bBCode + "   DF2FRACINC = 32 ; Column 2.<br>"
bBCode + "   DF3FRACINC = 32 ; Column 3.<br>"

Case 10
bBCode + "   ;  11 rows that are 16 scanlines high.<br>"
bBCode + "   ;<br>"
bBCode + "   DF6FRACINC = 32 ; Background colors.<br>"
bBCode + "   DF4FRACINC = 32 ; Playfield colors.<br><br>"
bBCode + "   DF0FRACINC = 16 ; Column 0.<br>"
bBCode + "   DF1FRACINC = 16 ; Column 1.<br>"
bBCode + "   DF2FRACINC = 16 ; Column 2.<br>"
bBCode + "   DF3FRACINC = 16 ; Column 3.<br>"

EndSelect

EndIf

;```````````````````````````````````````````````````````````````````````
;  Rest of the Main Loop and banks.
;
bBCode + "<br><br><br>"

bBCode + "   ;***************************************************************<br>"
bBCode + "   ;<br>"
bBCode + "   ;  Displays the screen.<br>"
bBCode + "   ;<br>"
bBCode + "   drawscreen<br><br><br><br>"

bBCode + "   goto __Main_Loop<br><br><br><br>"

If _Other_Kernels = 0
bBCode + "   bank 3<br>"
bBCode + "   temp1=temp1<br><br>"
bBCode + "   bank 4<br>"
bBCode + "   temp1=temp1<br><br>"
bBCode + "   bank 5<br>"
bBCode + "   temp1=temp1<br><br>"
bBCode + "   bank 6<br>"
bBCode + "   temp1=temp1<br>"
EndIf

bBCode + "</pre>"


ProcedureReturn bBCode

EndProcedure




;***********************************************************************
;***********************************************************************
;
;- NTSC COLOR TABLE
;
;  (The .s stands for STRING.)
;
Procedure.s Get_NTSC_ColorTable()

Protected Table.s
Protected Title.s, Color.s
Protected _NTSC_Row_Counter, _NTSC_Column_Counter
Protected _Atari_Counter

_Atari_Counter = 0

Restore NTSC

;```````````````````````````````````````````````````````````````````````
;  Creates the top row of numbers.
;
Table + "<table id='colorTable' border='1' cellspacing='0' bordercolordark='white' bordercolorlight='#A0A0A0' bordercolor='#A0A0A0' style='empty-cells: show; border-collapse: collapse; border-width:1px; border-color: #999; border-style:solid; margin-left: auto; margin-right: auto;'>"
Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px; width: 24px;'>"
Table + "</td>"
Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px; width: 24px;'>"
Table + "0"
Table + "</td>"
Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px; width: 24px;'>"
Table + "2"
Table + "</td>"
Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px; width: 24px;'>"
Table + "4"
Table + "</td>"
Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px; width: 24px;'>"
Table + "6"
Table + "</td>"
Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px; width: 24px;'>"
Table + "8"
Table + "</td>"
Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px; width: 24px;'>"
Table + "A"
Table + "</td>"
Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px; width: 24px;'>"
Table + "C"
Table + "</td>"
Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px; width: 24px;'>"
Table + "E"
Table + "</td>"

;```````````````````````````````````````````````````````````````````````
;  Loops for the NTSC chart.
;
For _NTSC_Row_Counter = 0 To 15
   Table + "<tr>"
For _NTSC_Column_Counter = 0 To 8

;```````````````````````````````````````````````````````````````````````
;  Creates a side number only at the beginning of each row.
;
If _NTSC_Column_Counter = 0

Table + "<td style='vertical-align: middle; text-align: center; line-height: 25px; height: 25px;'>"

Select _Atari_Counter
Case 0
Table + "0"
Case 1
Table + "1"
Case 2
Table + "2"
Case 3
Table + "3"
Case 4
Table + "4"
Case 5
Table + "5"
Case 6
Table + "6"
Case 7
Table + "7"
Case 8
Table + "8"
Case 9
Table + "9"
Case 10
Table + "A"
Case 11
Table + "B"
Case 12
Table + "C"
Case 13
Table + "D"
Case 14
Table + "E"
Case 15
Table + "F"

EndSelect

Table + "</td>"

;```````````````````````````````````````````````````````````````````````
;  Increases the Atari counter (for making side numbers).
;
   _Atari_Counter = _Atari_Counter + 1

EndIf 

;```````````````````````````````````````````````````````````````````````
;  Reads the data and creates the NTSC color box cells.
;
If _NTSC_Column_Counter > 0
Read.s Title
Read.s Color
Table + "<td title='" + Title + "' color='" + Color + "' style='background-color:" + Color + "'></td>"
EndIf

Next ; _NTSC_Column_Counter
Table + "</tr>"
Next ; _NTSC_Row_Counter

;```````````````````````````````````````````````````````````````````````
;  Finishes the NTSC chart.
;
Table + "</table>"

ProcedureReturn Table

EndProcedure




;***********************************************************************
;***********************************************************************
;
;- GADGET EVENTS
;
;  Handles all that happens during runtime.
;
Procedure GadgetEvents()

Protected _Which_Gadget = EventGadget()
Protected _Type = EventType()
Protected _Loop


;***********************************************************************
;
;  Control key check.
;
If GetGadgetAttribute(#Canvas_Playfield, #PB_Canvas_Modifiers) & #PB_Canvas_Control

;```````````````````````````````````````````````````````````````````````
;  Makes sure draw mode is on.
If _Button_Mode = #Button_Draw

;```````````````````````````````````````````````````````````````````````
;  Ctrl key memory check.
;
Select _Ctrl_Key_Memory

;```````````````````````````````````````````````````````````````````````
;  Ctrl key is being pressed from a released state.
Case 0

;```````````````````````````````````````````````````````````````````````
;  Removes any checkmarks from buttons.
For _Loop = #Button_Draw To #Button_Paint_BG_Row
SetGadgetState(_Loop, 0)
Next

;```````````````````````````````````````````````````````````````````````
;  Puts a check mark on the Erase button and sets mode to Erase.
SetGadgetState(#Button_Erase, 1)
_Button_Mode = #Button_Erase

;```````````````````````````````````````````````````````````````````````
;  Tells program that the Ctrl key is being held down.
_Ctrl_Key_Memory = 1

EndSelect

EndIf
EndIf




;***********************************************************************
;
;  Key release check.
;
Select EventType()

;```````````````````````````````````````````````````````````````````````
;  A key was released.
Case #PB_EventType_KeyUp

;```````````````````````````````````````````````````````````````````````
;  Checks the Ctrl key.
;
Select GetGadgetAttribute(#Canvas_Playfield, #PB_Canvas_Modifiers) & #PB_Canvas_Control

;```````````````````````````````````````````````````````````````````````
;  Ctrl key is off, so continue.
Case 0

;```````````````````````````````````````````````````````````````````````
;  Makes sure erase mode is on.
If _Button_Mode = #Button_Erase

;```````````````````````````````````````````````````````````````````````
;  Tells program that the Ctrl key is no longer pressed.
_Ctrl_Key_Memory = 0

;```````````````````````````````````````````````````````````````````````
;  Removes any checkmarks from buttons.
For _Loop = #Button_Draw To #Button_Paint_BG_Row
SetGadgetState(_Loop, 0)
Next

;```````````````````````````````````````````````````````````````````````
;  Puts a check mark on the Draw button and sets mode to Draw.
SetGadgetState(#Button_Draw, 1)
_Button_Mode = #Button_Draw

EndIf
EndSelect
EndSelect


;***********************************************************************
;
;  Checks which gadget was triggered.
;
Select _Which_Gadget

;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;
;  Canvas section.
;
Case #Canvas_Playfield

;```````````````````````````````````````````````````````````````````````
;  Keeps user from drawing if mouse pointer leaves the canvas while
;  left button is clicked, then mouse pointer moves back over with
;  left button released.
;
Select _Type

Case #PB_EventType_LeftButtonDown
_EnableDrawing = #True

Case #PB_EventType_MouseLeave
_EnableDrawing = #False

EndSelect

;```````````````````````````````````````````````````````````````````````
;  Canvas precheck.
;
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(#Canvas_Playfield, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton) 

If _EnableDrawing = #True And StartDrawing(CanvasOutput(#Canvas_Playfield))

;```````````````````````````````````````````````````````````````````````
;  Finds out which playfield column and row was clicked.
x = (GetGadgetAttribute(#Canvas_Playfield, #PB_Canvas_MouseX)/_Column_Scale)
y = (GetGadgetAttribute(#Canvas_Playfield, #PB_Canvas_MouseY)/(_Row_Height*_Row_Scale))


;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;-  Draw.
;
If _Button_Mode = #Button_Draw

;```````````````````````````````````````````````````````````````````````
;  Prevents drawing outside of boundary.
If x > 1 And x < 34 And y >= _Row_Start And y <= _Row_Limit

;```````````````````````````````````````````````````````````````````````
;  Remembers drawn playfield pixel using array.
_Playfield_Pixels(x, y*_Row_Height) = 1

;```````````````````````````````````````````````````````````````````````
;  Draws playfield pixel on the canvas.
Box(x*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Foreground_Colors(y*_Row_Height))

;```````````````````````````````````````````````````````````````````````
;- Multisprite mirror effect.
If _Other_Kernels = _Multisprite

If x < 18

xx = 35 - x

_Playfield_Pixels(xx, y*_Row_Height) = 1

Box(xx*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Foreground_Colors(y*_Row_Height))

_bB_playfield(xx-2, y-_Row_Start) = "X"

EndIf

If x > 17

yy = x - 18 : xx = 17 - yy

_Playfield_Pixels(xx, y*_Row_Height) = 1

Box(xx*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Foreground_Colors(y*_Row_Height))

_bB_playfield(xx-2, y-_Row_Start) = "X"

EndIf

EndIf

;```````````````````````````````````````````````````````````````````````
; Standard Kernel nbl: Paints a thin line of color from row above on top of pixel (if not top row).
If _Other_Kernels = _SK_no_blank_lines And y > _Row_Start
Box(x*_Column_Scale, (y*_Row_Height*_Row_Scale), _Column_Scale, 3, _Playfield_Foreground_Colors((y-1)*_Row_Height))
EndIf

;```````````````````````````````````````````````````````````````````````
;  Standard Kernel bl: Draws a thin background color line on top of row (if not top row).
If _Other_Kernels = _SK_with_blank_lines And y > _Row_Start
Box(x*_Column_Scale, (y*_Row_Height*_Row_Scale), _Column_Scale, 2, colorBG)
EndIf

;```````````````````````````````````````````````````````````````````````
;  Places an X in the bB array (for code generation).
_bB_playfield(x-2, y-_Row_Start) = "X"

EndIf


;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;  Erase.
;
ElseIf _Button_Mode = #Button_Erase

;```````````````````````````````````````````````````````````````````````
;  Prevents erasing outside of boundary.
If x > 1 And x < 34 And y >= _Row_Start And y <= _Row_Limit

;```````````````````````````````````````````````````````````````````````
;  Remembers erased playfield pixel using array.
_Playfield_Pixels(x, y*_Row_Height) = 0

;```````````````````````````````````````````````````````````````````````
;  Erases playfield pixel on the canvas.
Box(x*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Background_Colors(y*_Row_Height))

;```````````````````````````````````````````````````````````````````````
;- Multisprite mirror effect.
If _Other_Kernels = _Multisprite

If x < 18

xx = 35 - x

_Playfield_Pixels(xx, y*_Row_Height) = 0

Box(xx*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Background_Colors(y*_Row_Height))

_bB_playfield(xx-2, y-_Row_Start) = "."

EndIf

If x > 17

yy = x - 18 : xx = 17 - yy

_Playfield_Pixels(xx, y*_Row_Height) = 0

Box(xx*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Background_Colors(y*_Row_Height))

_bB_playfield(xx-2, y-_Row_Start) = "."

EndIf

EndIf

;```````````````````````````````````````````````````````````````````````
;  Places a . in the bB array (for code generation).
_bB_playfield(x-2, y-_Row_Start) = "."

EndIf


;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;  Paint Foreground Row.
;
ElseIf _Button_Mode = #Button_Paint_FG_Row

;```````````````````````````````````````````````````````````````````````
;  Prevents painting outside of boundary.
If x > 1 And x < 34 And y >= _Row_Start And y <= _Row_Limit

;```````````````````````````````````````````````````````````````````````
;  Gets current foreground color.
_Playfield_Foreground_Colors(y*_Row_Height) = colorFG

;```````````````````````````````````````````````````````````````````````
;  Puts row color in bar on left side.
Box(0, y*_Row_Scale*_Row_Height, 9, _Row_Height*_Row_Scale, colorFG)

;```````````````````````````````````````````````````````````````````````
;  Foreground row loop.
For _Loop = 0 To _32_Columns

;```````````````````````````````````````````````````````````````````````
;  Checks array for playfield pixel.
If _Playfield_Pixels(_Loop,y*_Row_Height) = 1

;```````````````````````````````````````````````````````````````````````
;  Draws playfield pixel on the canvas.
Box(_Loop*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, colorFG)

;```````````````````````````````````````````````````````````````````````
; Standard Kernel nbl: Paints a thin line of color from row above on top of pixel (if not top row).
If _Other_Kernels = _SK_no_blank_lines And y > _Row_Start
Box(_Loop*_Column_Scale, (y*_Row_Height*_Row_Scale), _Column_Scale, 3, _Playfield_Foreground_Colors((y-1)*_Row_Height))
EndIf

EndIf

;```````````````````````````````````````````````````````````````````````
;  Standard Kernel nbl: Paints a thin line of color on row below (if not bottom row).
If _Other_Kernels = _SK_no_blank_lines And y < _Row_Limit And _Playfield_Pixels(_Loop,(y+1)*_Row_Height) = 1
Box(_Loop*_Column_Scale, ((y+1)*_Row_Height*_Row_Scale), _Column_Scale, 3, _Playfield_Foreground_Colors(y*_Row_Height))
EndIf

;```````````````````````````````````````````````````````````````````````
;  Paints extra row down if 176 rows and an even row and pixel is on.
If _Row_Height = 1 And (y-_Row_Start) % 2 = 0 And _Playfield_Pixels(_Loop,(y+1)*_Row_Height) = 1
_Playfield_Foreground_Colors((y+1)*_Row_Height) = colorFG
Box(_Loop*_Column_Scale, (y+1)*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, colorFG)
Box(0, (y+1)*_Row_Scale*_Row_Height, 9, _Row_Height*_Row_Scale, colorFG)

;```````````````````````````````````````````````````````````````````````
;  Paints extra row up if 176 rows and an odd row and pixel is on.
ElseIf _Row_Height = 1 And (y-_Row_Start) % 2 = 1 And _Playfield_Pixels(_Loop,(y-1)*_Row_Height) = 1
_Playfield_Foreground_Colors((y-1)*_Row_Height) = colorFG
Box(_Loop*_Column_Scale, (y-1)*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, colorFG)
Box(0, (y-1)*_Row_Scale*_Row_Height, 9, _Row_Height*_Row_Scale, colorFG)
EndIf

Next

;```````````````````````````````````````````````````````````````````````
; Standard Kernel bl: Draws a thin background color line on top of row (if not top row).
If _Other_Kernels = _SK_with_blank_lines And y > _Row_Start
Box(30, (y*_Row_Height*_Row_Scale), 480, 2, colorBG)
EndIf

;```````````````````````````````````````````````````````````````````````
;- START multisprite kernel section (foreground).
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

;```````````````````````````````````````````````````````````````````````
;  Multisprite section
If _Other_Kernels = _Multisprite

;```````````````````````````````````````````````````````````````````````
;  Fills all rows of bB array with Atari 2600 color string (for code generation).
For _Loop = 0 To _bB_Rows
_bB_pfcolors(_Loop) = _Current_FG
Next

;```````````````````````````````````````````````````````````````````````
;  Loop for painting all rows the same foreground color.
For _Loop = _Row_Start To _Row_Limit

;```````````````````````````````````````````````````````````````````````
;  Puts foreground color in array.
_Playfield_Foreground_Colors(_Loop*_Row_Height) = colorFG

Next

;```````````````````````````````````````````````````````````````````````
;  Draws line down left side.
;
Box(0, 32, 9, 352, colorFG)

;```````````````````````````````````````````````````````````````````````
;  Loops for replacing foreground.
For _Row = _Row_Start To _Row_Limit
For _Column = 0 To _32_Columns

;```````````````````````````````````````````````````````````````````````
;  Paints FG if pixel is on.
If _Playfield_Pixels(_Column,_Row*_Row_Height) = 1
Box(_Column*_Column_Scale, _Row*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, colorFG)
EndIf

Next
Next

EndIf

;```````````````````````````````````````````````````````````````````````
; END multisprite kernel section (foreground).
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

;```````````````````````````````````````````````````````````````````````
;  Conversion for bB FG color array (for code generation).
yy = y-_Row_Start

;```````````````````````````````````````````````````````````````````````
;  Cuts bB FG color rows in half if 176 rows (can only be 88 rows of color).
If _Row_Height = 1
yy = yy / 2
EndIf

;```````````````````````````````````````````````````````````````````````
;  Places current foreground color in the bB array (for code generation).
_bB_pfcolors(yy) = _Current_FG

EndIf


;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;  Paint Background Row.
;
ElseIf _Button_Mode = #Button_Paint_BG_Row

;```````````````````````````````````````````````````````````````````````
;  Prevents painting outside of boundary.
If x > 1 And x < 34 And y >= _Row_Start And y <= _Row_Limit

;```````````````````````````````````````````````````````````````````````
;  Gets current background color.
_Playfield_Background_Colors(y*_Row_Height) = colorBG

;```````````````````````````````````````````````````````````````````````
;  Paints BG row.
Box(30, y*_Row_Height*_Row_Scale, 480, _Row_Height*_Row_Scale, colorBG) ; Paints row inside of border.
Box(10, y*_Row_Height*_Row_Scale, 18, _Row_Height*_Row_Scale, colorBG)  ; Paints row beyond left side of border.
Box(512, y*_Row_Height*_Row_Scale, 29, _Row_Height*_Row_Scale, colorBG) ; Paints row beyond right side of border.

;```````````````````````````````````````````````````````````````````````
;  Paints extra BG row down if 176 rows and an odd row and pixel is on.
If _Row_Height = 1 And (y-_Row_Start) % 2 = 0
_Playfield_Background_Colors((y+1)*_Row_Height) = colorBG
Box(30, (y+1)*_Row_Height*_Row_Scale, 480, _Row_Height*_Row_Scale, colorBG) ; Paints row inside of border.
Box(10, (y+1)*_Row_Height*_Row_Scale, 18, _Row_Height*_Row_Scale, colorBG)  ; Paints row beyond left side of border.
Box(512, (y+1)*_Row_Height*_Row_Scale, 29, _Row_Height*_Row_Scale, colorBG) ; Paints row beyond right side of border.

;```````````````````````````````````````````````````````````````````````
;  Paints extra BG row up if 176 rows and an odd row and pixel is on.
ElseIf _Row_Height = 1 And (y-_Row_Start) % 2 = 1
_Playfield_Background_Colors((y-1)*_Row_Height) = colorBG
Box(30, (y-1)*_Row_Height*_Row_Scale, 480, _Row_Height*_Row_Scale, colorBG) ; Paints row inside of border.
Box(10, (y-1)*_Row_Height*_Row_Scale, 18, _Row_Height*_Row_Scale, colorBG)  ; Paints row beyond left side of border.
Box(512, (y-1)*_Row_Height*_Row_Scale, 29, _Row_Height*_Row_Scale, colorBG) ; Paints row beyond right side of border.

EndIf

;```````````````````````````````````````````````````````````````````````
;- START other kernel section (background).
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

If _Other_Kernels > 0

;```````````````````````````````````````````````````````````````````````
;  Loop for painting all rows the same background color.
For _Loop = _Row_Start To _Row_Limit

;```````````````````````````````````````````````````````````````````````
;  Puts background color in array.
_Playfield_Background_Colors(_Loop*_Row_Height) = colorBG

;```````````````````````````````````````````````````````````````````````
;  Paints background row all one color.
Box(30, _Loop*_Row_Height*_Row_Scale, 480, _Row_Height*_Row_Scale, colorBG) ; Paints row inside of border.
Box(10, _Loop*_Row_Height*_Row_Scale, 18, _Row_Height*_Row_Scale, colorBG)  ; Paints row beyond left side of border.
Box(512, _Loop*_Row_Height*_Row_Scale, 29, _Row_Height*_Row_Scale, colorBG) ; Paints row beyond right side of border.
Next

;```````````````````````````````````````````````````````````````````````
;  Fills all rows of bB array with Atari 2600 color string (for code generation).
For _Loop = 0 To _bB_Rows
_bB_bkcolors(_Loop) = _Current_BG
Next

;```````````````````````````````````````````````````````````````````````
;  Loops for replacing foreground.
For _Row = _Row_Start To _Row_Limit
For _Column = 0 To _32_Columns

;```````````````````````````````````````````````````````````````````````
;  Paints FG if pixel is on.
If _Playfield_Pixels(_Column,_Row*_Row_Height) = 1

Box(_Column*_Column_Scale, _Row*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Foreground_Colors(_Row*_Row_Height))

;```````````````````````````````````````````````````````````````````````
; Standard Kernel nbl: Paints a thin line of color from row above on top of pixel (if not top row).
If _Other_Kernels = _SK_no_blank_lines And _Row > _Row_Start
Box(_Column*_Column_Scale, (_Row*_Row_Height*_Row_Scale), _Column_Scale, 3, _Playfield_Foreground_Colors((_Row-1)*_Row_Height))
EndIf

EndIf

;```````````````````````````````````````````````````````````````````````
;  Standard Kernel nbl: Paints a thin line of color on row below (if not bottom row).
If _Other_Kernels = _SK_no_blank_lines And _Row < _Row_Limit And _Playfield_Pixels(_Column,(_Row+1)*_Row_Height) = 1
Box(_Column*_Column_Scale, ((_Row+1)*_Row_Height*_Row_Scale), _Column_Scale, 3, _Playfield_Foreground_Colors(_Row*_Row_Height))
EndIf

Next

;```````````````````````````````````````````````````````````````````````
;  Standard Kernel bl: Draws a thin background color line on top of row (if not top row).
If _Other_Kernels = _SK_with_blank_lines And _Row > _Row_Start
Box(30, (_Row*_Row_Height*_Row_Scale), 480, 2, colorBG)
EndIf

Next

EndIf

;```````````````````````````````````````````````````````````````````````
;  END other kernel section.
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

If _Other_Kernels = 0

;```````````````````````````````````````````````````````````````````````
;  Loop for replacing foreground.
For _Loop = 0 To _32_Columns

;```````````````````````````````````````````````````````````````````````
;  Paints FG if pixel is on.
If _Playfield_Pixels(_Loop,y*_Row_Height) = 1
Box(_Loop*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Foreground_Colors(y*_Row_Height))
EndIf

;```````````````````````````````````````````````````````````````````````
;  Paints extra FG row down if 176 rows and an even row and pixel is on.
If _Row_Height = 1 And (y-_Row_Start) % 2 = 0 And _Playfield_Pixels(_Loop,(y+1)*_Row_Height) = 1
Box(_Loop*_Column_Scale, (y+1)*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Foreground_Colors((y+1)*_Row_Height))

;```````````````````````````````````````````````````````````````````````
;  Paints extra FG row up if 176 rows and an odd row and pixel is on.
ElseIf _Row_Height = 1 And (y-_Row_Start) % 2 = 1 And _Playfield_Pixels(_Loop,(y-1)*_Row_Height) = 1
Box(_Loop*_Column_Scale, (y-1)*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Foreground_Colors((y-1)*_Row_Height))

EndIf

Next

EndIf

;```````````````````````````````````````````````````````````````````````
;  Conversion for bB BG color array (for code generation).
yy = y-_Row_Start

;```````````````````````````````````````````````````````````````````````
;  Cuts BG color rows in half if 176 rows (can only be 88 rows of color).
If _Row_Height = 1
yy = yy / 2
EndIf

;```````````````````````````````````````````````````````````````````````
;  Places current background color in the bB array (for code generation).
_bB_bkcolors(yy) = _Current_BG

EndIf
EndIf
StopDrawing()
EndIf
EndIf


;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;
;- Row Mode check. If a new mode is selected, the canvas playfield is
;  also cleared.
;
Case #Row_Mode_Dropdown_Menu

_Drop_Down = GetGadgetState(#Row_Mode_Dropdown_Menu)

If _Type = #PB_EventType_Change

_Other_Kernels = 0

Select _Drop_Down

Case 0  ; DPC+ kernel with 176 rows and 88 rows of color.
Dim _bB_playfield.s(32, 176)
Dim _bB_pfcolors.s(88)
Dim _bB_bkcolors.s(88)
_bB_Rows = 175 : _Row_Start = 16 : _Row_Limit = 191 : _Row_Height = 1

Case 1  ; DPC+ kernel with 88 rows.
Dim _bB_playfield.s(32, 88)
Dim _bB_pfcolors.s(88)
Dim _bB_bkcolors.s(88)
_bB_Rows = 87 : _Row_Start = 8 : _Row_Limit = 95 : _Row_Height = 2

Case 2  ; DPC+ kernel with 44 rows.
Dim _bB_playfield.s(32, 44)
Dim _bB_pfcolors.s(44)
Dim _bB_bkcolors.s(44)
_bB_Rows = 43 : _Row_Start = 4 : _Row_Limit = 47 : _Row_Height = 4

Case 3  ; DPC+ kernel with 22 rows.
Dim _bB_playfield.s(32, 22)
Dim _bB_pfcolors.s(22)
Dim _bB_bkcolors.s(22)
_bB_Rows = 21 : _Row_Start = 2 : _Row_Limit = 23 : _Row_Height = 8

Case 4  ; DPC+ kernel with 11 rows.
Dim _bB_playfield.s(32, 11)
Dim _bB_pfcolors.s(11)
Dim _bB_bkcolors.s(11)
_bB_Rows = 10 : _Row_Start = 1 : _Row_Limit = 11 : _Row_Height = 16

Case 5  ; Standard kernel with blank lines.
Dim _bB_playfield.s(32, 11)
Dim _bB_pfcolors.s(11)
Dim _bB_bkcolors.s(11)
_bB_Rows = 10 : _Row_Start = 1 : _Row_Limit = 11 : _Row_Height = 16 : _Other_Kernels = _SK_with_blank_lines

Case 6  ; Standard kernel no_blank_lines.
Dim _bB_playfield.s(32, 11)
Dim _bB_pfcolors.s(11)
Dim _bB_bkcolors.s(11)
_bB_Rows = 10 : _Row_Start = 1 : _Row_Limit = 11 : _Row_Height = 16 : _Other_Kernels = _SK_no_blank_lines

Case 7  ; Multisprite kernel with 44 rows.
Dim _bB_playfield.s(32, 44)
Dim _bB_pfcolors.s(44)
Dim _bB_bkcolors.s(44)
_bB_Rows = 43 : _Row_Start = 4 : _Row_Limit = 47 : _Row_Height = 4 : _Other_Kernels = _Multisprite

Case 8  ; Multisprite kernel with 22 rows.
Dim _bB_playfield.s(32, 22)
Dim _bB_pfcolors.s(22)
Dim _bB_bkcolors.s(22)
_bB_Rows = 21 : _Row_Start = 2 : _Row_Limit = 23 : _Row_Height = 8 : _Other_Kernels = _Multisprite

Case 9  ; Multisprite kernel with 11 rows.
Dim _bB_playfield.s(32, 11)
Dim _bB_pfcolors.s(11)
Dim _bB_bkcolors.s(11)
_bB_Rows = 10 : _Row_Start = 1 : _Row_Limit = 11 : _Row_Height = 16 : _Other_Kernels = _Multisprite

EndSelect

ClearPlayfield()

EndIf


;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;
;  Button click check. If a button is clicked, all buttons are cleared
;  and the new button is selected.
;
Case #Button_Draw To #Button_Paint_BG_Row

;```````````````````````````````````````````````````````````````````````
;  Removes any checkmarks from buttons.
For _Loop = #Button_Draw To #Button_Paint_BG_Row
SetGadgetState(_Loop, 0)
Next

;```````````````````````````````````````````````````````````````````````
;  Puts a check mark on the correct button and sets button mode.
SetGadgetState(_Which_Gadget, 1)
_Button_Mode = _Which_Gadget


;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;- NTSC COLOR WINDOW POPUP
;
;  Appears when user clicks on a foreground/background color box.
;
Case #Foreground_Color_Box, #Background_Color_Box
_Which_Color_FG_or_BG = _Which_Gadget

OpenWindow(#Window_NTSC_Color_Chart, WindowMouseX(#Window_Main)-200, WindowMouseY(#Window_Main)-250, 
300, 500, "Color NTSC");, #PB_Window_BorderLess)
ContainerGadget(#NTSC_Gadget, 0, 0, WindowWidth(#Window_NTSC_Color_Chart), WindowHeight(#Window_NTSC_Color_Chart))

GID = GadgetID(#NTSC_Gadget)
SetWindowColor(#Window_NTSC_Color_Chart, $FFFFFF)

;```````````````````````````````````````````````````````````````````````
;  Inline JavaScript magic.
;
;  A JavaScript variable name is the same as a SpiderBasic variable
;  name, but the JavaScript version is all lowercase and has a
;  'v_' prefix. It's the same for local variables, global variables
;  and function parameters.
;
;  A JavaScript procedure name is the same as a SpiderBasic procedure
;  name, but the JavaScript version is all lowercase and has an
;  'f_' prefix.
;
;  Line 1: Clears the div.
;  Line 2: Inserts content using append().
;  Line 3: Onclick magic.
;  Line 4: Procedure magic.
;
! $(v_gid.div).empty();
! $(v_gid.div).append($(v_ntsc_colortable));
! $('#colorTable').on('click','td', function() {
!   f_colorcellclicked($(this).attr("title"), $(this).attr("color"));
! });

;```````````````````````````````````````````````````````````````````````
;  Makes NTSC color chart disappear if mouse pointer leaves area.
;
AddWindowTimer(#Window_NTSC_Color_Chart, 0, 100)


;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;
;  Clear Button check. (Clears canvas playfield if button clicked.)
;
Case #Button_Clear
ClearPlayfield()


;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;
;  Generate bB code button check. If clicked, opens window, gets
;  bB code, and makes it selectable.
;
Case #Button_Generate_Code

OpenWindow(#bB_Code_Window, WindowMouseX(#Window_Main)-350, WindowMouseY(#Window_Main)-480, 
700, 500, "bB Code");, #PB_Window_BorderLess)
ScrollAreaGadget(#bB_Gadget, 0, 0, 700, 500, 700, 500)
SetGadgetColor(#bB_Gadget, #PB_Gadget_BackColor, $FFFFFF)

bB_CodeTable = bB_Procedure()

GID = GadgetID(#bB_Gadget)
! $(v_gid.div).empty();
! $(v_gid.div).append($(v_bb_codetable));
! $(v_gid.div).css("user-select", "all");
EndSelect

EndProcedure



;***********************************************************************
;***********************************************************************
;
;- USER INTERFACE SETUP
;
Procedure initUI()
;
;```````````````````````````````````````````````````````````````````````
;  Main window and user interface.
;
LoadFont(#Font_UiBig, fontUiBig, fontUiBigSize, #PB_Font_Bold)
LoadFont(#Font_UiNormal, fontUiNormal, fontUiNormalSize, #PB_Font_Bold)
LoadFont(#Font_UiSmall, fontUiSmall, fontUiSmallSize)

If OpenWindow(#Window_Main, 0, 0, 0, 0, #AppName, #PB_Window_Background)
SetWindowColor(#Window_Main, colorWindowBG)

;```````````````````````````````````````````````````````````````````````
;-  CANVAS: Playfield area for drawing.
;
CanvasGadget(#Canvas_Playfield, 4*_Spacer, 4*_Spacer, 542, 417, #PB_Canvas_Border | #PB_Canvas_Keyboard)

;```````````````````````````````````````````````````````````````````````
;  BUTTON: Clear playfield canvas.
;
ButtonGadget(#Button_Clear, GadgetX(#Canvas_Playfield), GadgetY(#Canvas_Playfield)+GadgetHeight(#Canvas_Playfield)+3*_Spacer,
80, 30, "Clear")

;```````````````````````````````````````````````````````````````````````
;  BUTTON: Generate bB code.
;
ButtonGadget(#Button_Generate_Code, GadgetX(#Button_Clear)+GadgetWidth(#Canvas_Playfield)-130, GadgetY(#Button_Clear),
130, 30, "Generate bB Code")

;```````````````````````````````````````````````````````````````````````
;  DROPDOWN MENU: Row Mode.
;
TextGadget(#Text_for_Row_Mode, GadgetX(#Canvas_Playfield)+GadgetWidth(#Canvas_Playfield)+3*_Spacer, GadgetY(#Canvas_Playfield), 
200, fontUiNormalSize, "Row Mode")
SetGadgetFont(#Text_for_Row_Mode, FontID(#Font_UiNormal))
SetGadgetColor(#Text_for_Row_Mode, #PB_Gadget_FrontColor, _Text_Color)

ComboBoxGadget(#Row_Mode_Dropdown_Menu, GadgetX(#Text_for_Row_Mode), GadgetY(#Text_for_Row_Mode)+fontUiNormalSize+_Spacer, 240, 30)
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " DPC+ 176 rows")
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " DPC+ 88 rows")
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " DPC+ 44 rows")
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " DPC+ 22 rows")
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " DPC+ 11 rows")
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " Standard 11 rows")
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " Standard no_blank_lines 11 rows")
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " Multisprite 44 rows")
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " Multisprite 22 rows")
AddGadgetItem(#Row_Mode_Dropdown_Menu, -1, " Multisprite 11 rows")
SetGadgetState(#Row_Mode_Dropdown_Menu, 1)

;```````````````````````````````````````````````````````````````````````
;  TEXT: Editing.
;
TextGadget(#Text_for_Editing_Mode, GadgetX(#Text_for_Row_Mode), GadgetY(#Row_Mode_Dropdown_Menu)+30+3*_Spacer, 240, fontUiNormalSize, "Editing Mode")
SetGadgetFont(#Text_for_Editing_Mode, FontID(#Font_UiNormal))
SetGadgetColor(#Text_for_Editing_Mode, #PB_Gadget_FrontColor, _Text_Color)

;```````````````````````````````````````````````````````````````````````
;
;  NOTE: "#PB_Button_Toggle" creates a toggle button (one click pushes
;  it, another will release it.)
;
;```````````````````````````````````````````````````````````````````````

;```````````````````````````````````````````````````````````````````````
;  BUTTON: Draw playfield pixel.
;
ButtonGadget(#Button_Draw, GadgetX(#Text_for_Row_Mode), GadgetY(#Text_for_Editing_Mode)+fontUiNormalSize+_Spacer, 115, 30,
"Draw", #PB_Button_Toggle )

;```````````````````````````````````````````````````````````````````````
;  BUTTON: Erase playfield pixel.
;
ButtonGadget(#Button_Erase, GadgetX(#Text_for_Row_Mode)+120, GadgetY(#Text_for_Editing_Mode)+fontUiNormalSize+_Spacer, 115, 30,
"Erase", #PB_Button_Toggle)

;```````````````````````````````````````````````````````````````````````
;  BUTTON: Paint FG row.
;
ButtonGadget(#Button_Paint_FG_Row, GadgetX(#Text_for_Row_Mode), GadgetY(#Text_for_Editing_Mode)+fontUiNormalSize+_Spacer+35, 115, 30,
"Paint FG Row", #PB_Button_Toggle )

;```````````````````````````````````````````````````````````````````````
;  BUTTON: Paint BG row.
;
ButtonGadget(#Button_Paint_BG_Row, GadgetX(#Button_Paint_FG_Row)+120, GadgetY(#Text_for_Editing_Mode)+fontUiNormalSize+_Spacer+35, 115, 30,
"Paint BG Row", #PB_Button_Toggle)

;```````````````````````````````````````````````````````````````````````
;  Selects starting button mode.
;
SetGadgetState(#Button_Draw, 1)  ; Puts a check mark on the Draw button.
_Button_Mode = #Button_Draw      ; Selects the Draw button.

;```````````````````````````````````````````````````````````````````````
;  Foreground Color text and clickable box that brings up the NTSC chart.
;
TextGadget(#Text_for_Foreground_Color, GadgetX(#Text_for_Row_Mode), GadgetY(#Button_Paint_FG_Row)+35+3*_Spacer, 152, fontUiNormalSize, "Foreground Color")
SetGadgetFont(#Text_for_Foreground_Color, FontID(#Font_UiNormal))
SetGadgetColor(#Text_for_Foreground_Color, #PB_Gadget_FrontColor, _Text_Color)
ButtonGadget(#Foreground_Color_Box, GadgetX(#Text_for_Foreground_Color)+GadgetWidth(#Text_for_Foreground_Color), GadgetY(#Text_for_Foreground_Color)-5, 60, 30, "")
GID=GadgetID(#Foreground_Color_Box)
! $(v_gid.div).find(".dijitButtonContents").css("background-color", spider_helper_ColorToHtml(v_colorfg));

;```````````````````````````````````````````````````````````````````````
;  Background Color text and clickable box that brings up the NTSC chart.
;
TextGadget(#Text_for_Background_Color, GadgetX(#Text_for_Row_Mode), GadgetY(#Button_Paint_FG_Row)+75+3*_Spacer, 152, fontUiNormalSize, "Background Color")
SetGadgetFont(#Text_for_Background_Color, FontID(#Font_UiNormal))
SetGadgetColor(#Text_for_Background_Color, #PB_Gadget_FrontColor, _Text_Color)
ButtonGadget(#Background_Color_Box, GadgetX(#Text_for_Background_Color)+GadgetWidth(#Text_for_Background_Color), GadgetY(#Text_for_Background_Color)-5, 60, 30, "")

GID=GadgetID(#Background_Color_Box)

;```````````````````````````````````````````````````````````````````````
;  Inline JavaScript magic.
;
! $(v_gid.div).find(".dijitButtonContents").css("background-color", spider_helper_ColorToHtml(v_colorbg));

;```````````````````````````````````````````````````````````````````````
;  Footer with version number and more.
;
TextGadget(#Text_for_Footer, GadgetX(#Canvas_Playfield), GadgetY(#Button_Clear)+GadgetHeight(#Button_Clear)+3*_Spacer,
_32_Columns*_Column_Scale*3, fontUiSmallSize, textFooter)
SetGadgetFont(#Text_for_Footer, FontID(#Font_UiSmall))
SetGadgetColor(#Text_for_Footer, #PB_Gadget_FrontColor, _Text_Color)

EndIf

EndProcedure



;***********************************************************************
;***********************************************************************
;
;- START OF PROGRAM (POINT OF ENTRY)
;
Global NTSC_ColorTable.s = Get_NTSC_ColorTable()
initUI()
BindEvent(#PB_Event_Gadget, @GadgetEvents())
BindEvent(#PB_Event_CloseWindow, @WindowEvents())
BindEvent(#PB_Event_Timer, @TimerEvents())
BindEvent(#PB_Event_CloseWindow, @CloseWindowEvent())

;```````````````````````````````````````````````````````````````````````
;  Clears the playfield canvas.
;
StartDrawing(CanvasOutput(#Canvas_Playfield))
Box(0, 0, 551, 417, $E9EAEA)
StopDrawing()

;```````````````````````````````````````````````````````````````````````
;- Creates black box around playfield area.
;
StartDrawing(CanvasOutput(#Canvas_Playfield))
Box(28, 30, 484, 356, #White)
Box(29, 31, 481.5, 354, #Black)
Box(30, 32, 480, 352, $E9EAEA)
StopDrawing()

;```````````````````````````````````````````````````````````````````````
;  Draws black line down left side.
;
Box(0, 32, 9, 352, #Black)

;```````````````````````````````````````````````````````````````````````
;  Puts the starting default colors into the foreground and background.
;
For _Loop = 0 To 220
_Playfield_Foreground_Colors(_Loop) = colorFG
_Playfield_Background_Colors(_Loop) = colorBG
Next

;```````````````````````````````````````````````````````````````````````
;  Fills the bB playfield array with dots.
;
For _Row = 0 To _bB_Rows

For _Column = 0 To 31

_bB_playfield(_Column, _Row) = "."

Next
Next

;```````````````````````````````````````````````````````````````````````
;  Fills the bB pfcolors array with black.
;
For _Row = 0 To _bB_Rows

_bB_pfcolors(_Row) = "$00"

Next

;```````````````````````````````````````````````````````````````````````
;  Fills the bB bkcolors array with white.
;
For _Row = 0 To _bB_Rows

_bB_bkcolors(_Row) = "$0E"

Next


;***********************************************************************
;***********************************************************************
;
;- DATA SECTION FOR NTSC COLOR CHART
;
;  (The .s stands for STRING.)
;
DataSection

NTSC:
Data.s "$00", "#000000", "$02", "#3F3F3E", "$04", "#646463", "$06", "#848483", "$08", "#A2A2A1", "$0A", "#BABAB9", "$0C", "#D2D2D1", "$0E", "#EAEAE9"
Data.s "$10", "#3D3D00", "$12", "#5E5E0A", "$14", "#7B7B15", "$16", "#999920", "$18", "#B4B42A", "$1A", "#CDCD34", "$1C", "#E6E63E", "$1E", "#FDFD48"
Data.s "$20", "#712300", "$22", "#863D0B", "$24", "#995718", "$26", "#AD6F26", "$28", "#BD8632", "$2A", "#CD9B3E", "$2C", "#DCB049", "$2E", "#EAC254"
Data.s "$30", "#861500", "$32", "#9A2F0E", "$34", "#AE481E", "$36", "#C0612F", "$38", "#D1773E", "$3A", "#E08D4D", "$3C", "#EFA25B", "$3E", "#FDB568"

Data.s "$40", "#8A0000", "$42", "#9E1312", "$44", "#B12827", "$46", "#C23D3C", "$48", "#D25150", "$4A", "#E26463", "$4C", "#EF7574", "$4E", "#FD8685"
Data.s "$50", "#790058", "$52", "#8D126E", "$54", "#A02784", "$56", "#B13B98", "$58", "#C04EAA", "$5A", "#D061BC", "$5C", "#DD71CC", "$5E", "#EA82DC"
Data.s "$60", "#450078", "$62", "#5D128F", "$64", "#7227A4", "$66", "#883BB9", "$68", "#9B4ECA", "$6A", "#AE61DC", "$6C", "#BF71EC", "$6E", "#D082FB"
Data.s "$70", "#0E0085", "$72", "#291399", "$74", "#4328AD", "$76", "#5D3DBF", "$78", "#7451D0", "$7A", "#8B64DF", "$7C", "#A175EE", "$7E", "#B586FB"
Data.s "$80", "#00008A", "$82", "#12139D", "$84", "#2428B0", "$86", "#373DC1", "$88", "#4951D1", "$8A", "#5A64E0", "$8C", "#6A75EE", "$8E", "#7986FB"
Data.s "$90", "#00157D", "$92", "#123193", "$94", "#244CA7", "$96", "#3767BB", "$98", "#4980CC", "$9A", "#5A97DD", "$9C", "#6AAEED", "$9E", "#79C2FB"
Data.s "$A0", "#002758", "$A2", "#124574", "$A4", "#24628D", "$A6", "#377EA7", "$A8", "#4997BE", "$AA", "#5AB0D4", "$AC", "#6AC7E8", "$AE", "#79DDFB"
Data.s "$B0", "#003526", "$B2", "#125742", "$B4", "#24765D", "$B6", "#379576", "$B8", "#49B18E", "$BA", "#5ACCA5", "$BC", "#6AE5BB", "$BE", "#79FDCF"
Data.s "$C0", "#003900", "$C2", "#135B12", "$C4", "#287927", "$C6", "#3D973C", "$C8", "#51B350", "$CA", "#64CD63", "$CC", "#75E674", "$CE", "#86FD85"
Data.s "$D0", "#0E3200", "$D2", "#2B5411", "$D4", "#477323", "$D6", "#639336", "$D8", "#7DB048", "$DA", "#95CB59", "$DC", "#ADE569", "$DE", "#C2FD78"
Data.s "$E0", "#272E00", "$E2", "#454E0F", "$E4", "#626B21", "$E6", "#7E8833", "$E8", "#97A343", "$EA", "#B0BC53", "$EC", "#C7D462", "$EE", "#DDEA70"
Data.s "$F0", "#3D2300", "$F2", "#5E420D", "$F4", "#7B5F1D", "$F6", "#997B2D", "$F8", "#B4963B", "$FA", "#CDAF4A", "$FC", "#E6C757", "$FE", "#FDDD64"
EndDataSection

Back to Top

 

 

In Case You Didn't Know

 

Trump's Jab = Bad

Did you know that Trump's rushed Operation Warp Speed rona jab has less than one percent overall benefit? Some people call it the depopulation jab and it has many possible horrible side effects (depending on the lot number, concentration, and if it was kept cold). Remember when many Democrats were against Trump's Operation Warp Speed depopulation jab, then they quickly changed their minds when Biden flip-flopped and started pushing it?

 

Some brainwashed rona jab cultists claim that there are no victims of the jab, but person after person will post what the jab did to them, a friend, or a family member on web sites such as Facebook and they'll be lucky if they don't get banned soon after. Posting the truth is “misinformation” don't you know. Awakened sheep might turn into lions, so powerful people will do just about anything to keep the sheep from waking up.

 

Check out these videos:

If You Got the COVID Shot and Aren't Injured, This May Be Why

Thought Experiment: What Happens After the Jab?

The Truth About Polio and Vaccines

What Is Causing the Mysterious Self-Assembling Non-Organic Clots and Sudden Deaths?

Full Video of Tennessee House of Representatives Health Subcommittee Hearing Room 2 (The Doctors Start Talking at 33:28)

 

 

H Word and I Word = Good

Take a look at my page about the famous demonized medicines called The H Word and Beyond. You might also want to look at my page called Zinc and Quercetin. My sister and I have been taking zinc and quercetin since the summer of 2020 in the hopes that they would scare away the flu and other viruses (or at least make them less severe). Here's one more page to check out: My Sister's Experiences With COVID-19.

 

 

B Vitamins = Good

Some people appear to have a mental illness because they have a vitamin B deficiency. For example, the wife of a guy I used to chat with online had severe mood swings which seemed to be caused by food allergies or intolerances. She would became irrational, obnoxious, throw tantrums, and generally act like she had a mental illness. The horrid behavior stopped after she started taking a vitamin B complex. I've been taking Jarrow B-Right (#ad) for many years. It makes me much easier to live with.

 

 

Soy = Bad

Unfermented soy is bad! “When she stopped eating soy, the mental problems went away.” Fermented soy doesn't bother me, but the various versions of unfermented soy (soy flour, soybean oil, and so on) that are used in all kinds of products these days causes a negative mental health reaction in me that a vitamin B complex can't tame. The sinister encroachment of soy has made the careful reading of ingredients a necessity.

 

 

Wheat = Bad

If you are overweight, have type II diabetes, or are worried about the condition of your heart, check out the videos by Ken D Berry, William Davis, and Ivor Cummins. It seems that most people should avoid wheat, not just those who have a wheat allergy or celiac disease. Check out these books: Undoctored (#ad), Wheat Belly (#ad), and Eat Rich, Live Long (#ad).

 

 

Negative Ions = Good

Negative ions are good for us. You might want to avoid positive ion generators and ozone generators. A plain old air cleaner is better than nothing, but one that produces negative ions makes the air in a room fresher and easier for me to breathe. It also helps to brighten my mood.

 

 

Litterbugs = Bad

Never litter. Toss it in the trash or take it home. Do not throw it on the ground. Also remember that good people clean up after themselves at home, out in public, at a campsite and so on. Leave it better than you found it.

 

 

Climate Change Cash Grab = Bad

Seems like more people than ever finally care about water, land, and air pollution, but the climate change cash grab scam is designed to put more of your money into the bank accounts of greedy politicians. Those power-hungry schemers try to trick us with bad data and lies about overpopulation while pretending to be caring do-gooders. Trying to eliminate pollution is a good thing, but the carbon footprint of the average law-abiding human right now is actually making the planet greener instead of killing it.

 

Eliminating farms and ranches, eating bugs, getting locked down in 15-minute cities, owning nothing, using digital currency (with expiration dates) that is tied to your social credit score, and paying higher taxes will not make things better and “save the Earth.” All that stuff is part of an agenda that has nothing to do with making the world a better place for the average person. It's all about control, depopulation, and making things better for the ultra-rich. They just want enough peasants left alive to keep things running smoothly.

 

Watch these two videos for more information:

CO2 is Greening The Earth

The Climate Agenda

 

 

How to Wake Up Normies

Charlie Robinson had some good advice about waking up normies (see the link to the video below). He said instead of verbally unloading or being nasty or acting like a bully, ask the person a question. Being nice and asking a question will help the person actually think about the subject.

 

Interesting videos:

Charlie Robinson Talks About the Best Way to Wake Up Normies

Georgia Guidestones Explained

The Men Who Own Everything

Disclaimer

View this page and any external web sites at your own risk. I am not responsible for any possible spiritual, emotional, physical, financial or any other damage to you, your friends, family, ancestors, or descendants in the past, present, or future, living or dead, in this dimension or any other.

 

Use this playfield editor at your own risk. I am not responsible for lost data or other problems that may pop up.

 

Home Inventions Quotations Game Design Atari Memories Personal Pages About Site Map Contact Privacy Policy Tip Jar