... and here comes PART 2:
Code: Select all
bBCode + " ;<br>"
bBCode + " drawscreen<br><br><br><br>"
bBCode + " goto __Main_Loop<br><br><br><br>"
If _Standard_Kernel = 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
Protected i, j
;***********************************************************************
;
; 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.
;
; Also adds a new UNDO step if a drawing was performed.
;
Select _Type
Case #PB_EventType_LeftButtonDown
_EnableDrawing = #True
;- undo redo
Case #PB_EventType_MouseLeave, #PB_EventType_LeftButtonUp
If _EnableDrawing = #True
AddElement(undo())
_Undo_Position = ListIndex(undo())
If ListSize(undo()) > _Max_Undo_Steps
If _Undo_Position > ListSize(undo())*0.5
FirstElement(undo())
DeleteElement(undo())
_Undo_Position -1
Else
LastElement(undo())
DeleteElement(undo())
EndIf
EndIf
If _Undo_Position < 0
_Undo_Position = 0
EndIf
SelectElement(undo(), _Undo_Position)
For i=0 To 40
For j=0 To 220
undo()\playfield(i,j) = _Playfield_Pixels(i,j)
Next
Next
For j=0 To 220
undo()\foreground(j) = _Playfield_Foreground_Colors(j)
undo()\background(j) = _Playfield_Foreground_Colors(j)
Next
DisableGadget(#Button_Undo, #False)
EndIf
_EnableDrawing = #False
Case #PB_EventType_MouseEnter
SetGadgetAttribute(#Canvas_Playfield, #PB_Canvas_Cursor, #PB_Cursor_Cross)
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
If x > 1 And x < 34 And y >= _Row_Start And y <= _Row_Limit
_Playfield_Pixels(x, y*_Row_Height) = 1
Box(x*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Foreground_Colors(y*_Row_Height))
Debug _Playfield_Foreground_Colors(y*_Row_Height)
If _Standard_Kernel = 2 And y > _Row_Start ; Draws a thin line on top of pixel if not on top row.
Box(x*_Column_Scale, (y*_Row_Height*_Row_Scale), _Column_Scale, 3, _Playfield_Foreground_Colors((y-1)*_Row_Height))
EndIf
If _Standard_Kernel = 1 And y > _Row_Start ; Draws a thin line on top of pixel if not on top row.
Box(x*_Column_Scale, (y*_Row_Height*_Row_Scale), _Column_Scale, 2, colorBG)
EndIf
_bB_playfield(x-2, y-_Row_Start) = "X"
EndIf
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
; Erase.
;
ElseIf _Button_Mode = #Button_Erase
If x > 1 And x < 34 And y >= _Row_Start And y <= _Row_Limit
_Playfield_Pixels(x, y*_Row_Height) = 0
Box(x*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, _Playfield_Background_Colors(y*_Row_Height))
_bB_playfield(x-2, y-_Row_Start) = "."
EndIf
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
; Paint Foreground Row.
;
ElseIf _Button_Mode = #Button_Paint_FG_Row
If x > 1 And x < 34 And y >= _Row_Start And y <= _Row_Limit
_Playfield_Foreground_Colors(y*_Row_Height) = colorFG
Box(0, y*_Row_Scale*_Row_Height, 9, _Row_Height*_Row_Scale, colorFG)
For _Loop = 0 To _32_Columns
If _Playfield_Pixels(_Loop,y*_Row_Height) = 1
Box(_Loop*_Column_Scale, y*_Row_Scale*_Row_Height, _Column_Scale, _Row_Height*_Row_Scale, colorFG)
If _Standard_Kernel = 2 And y > _Row_Start ; Draws a thin line on top of pixel if not on top row.
Box(_Loop*_Column_Scale, (y*_Row_Height*_Row_Scale), _Column_Scale, 3, _Playfield_Foreground_Colors((y-1)*_Row_Height))
EndIf
EndIf
If _Standard_Kernel = 2 And y < _Row_Limit And _Playfield_Pixels(_Loop,(y+1)*_Row_Height) = 1 ; Draws on row below.
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
If _Standard_Kernel = 1 And y > _Row_Start ; Draws a thin line on top of row if not drawing on top row.
Box(30, (y*_Row_Height*_Row_Scale), 480, 2, colorBG)
EndIf
yy = y-_Row_Start
;```````````````````````````````````````````````````````````````````````
; Cuts FG color rows in half if 176 rows (can only be 88 rows of color).
If _Row_Height = 1
yy = yy / 2
EndIf
_bB_pfcolors(yy) = _Current_FG
EndIf
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
; Paint Background Row.
;
ElseIf _Button_Mode = #Button_Paint_BG_Row
If x > 1 And x < 34 And y >= _Row_Start And y <= _Row_Limit
_Playfield_Background_Colors(y*_Row_Height) = colorBG
;```````````````````````````````````````````````````````````````````````
; Paints BG row.
Box(30, y*_Row_Height*_Row_Scale, 480, _Row_Height*_Row_Scale, colorBG)
Box(10, y*_Row_Height*_Row_Scale, 19, _Row_Height*_Row_Scale, colorBG)
Box(511, y*_Row_Height*_Row_Scale, 29, _Row_Height*_Row_Scale, colorBG)
;```````````````````````````````````````````````````````````````````````
; 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)
Box(10, (y+1)*_Row_Height*_Row_Scale, 19, _Row_Height*_Row_Scale, colorBG)
Box(511, (y+1)*_Row_Height*_Row_Scale, 29, _Row_Height*_Row_Scale, colorBG)
;```````````````````````````````````````````````````````````````````````
; 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)
Box(10, (y-1)*_Row_Height*_Row_Scale, 19, _Row_Height*_Row_Scale, colorBG)
Box(511, (y-1)*_Row_Height*_Row_Scale, 29, _Row_Height*_Row_Scale, colorBG)
EndIf
;```````````````````````````````````````````````````````````````````````
; Standard kernel section.
;
If _Standard_Kernel = 1 Or _Standard_Kernel = 2
;```````````````````````````````````````````````````````````````````````
; Paints BG all one color.
For _Loop = _Row_Start To _Row_Limit
_Playfield_Background_Colors(_Loop*_Row_Height) = colorBG
Box(30, _Loop*_Row_Height*_Row_Scale, 480, _Row_Height*_Row_Scale, colorBG)
Box(10, _Loop*_Row_Height*_Row_Scale, 19, _Row_Height*_Row_Scale, colorBG)
Box(511, _Loop*_Row_Height*_Row_Scale, 29, _Row_Height*_Row_Scale, colorBG)
Next
For _Loop = 0 To 10
_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))
If _Standard_Kernel = 2 And _Row > _Row_Start ; Draws a thin line on top of pixel if not on top row.
Box(_Column*_Column_Scale, (_Row*_Row_Height*_Row_Scale), _Column_Scale, 3, _Playfield_Foreground_Colors((_Row-1)*_Row_Height))
EndIf
EndIf
If _Standard_Kernel = 2 And _Row < _Row_Limit And _Playfield_Pixels(_Column,(_Row+1)*_Row_Height) = 1 ; Draws on row below.
Box(_Column*_Column_Scale, ((_Row+1)*_Row_Height*_Row_Scale), _Column_Scale, 3, _Playfield_Foreground_Colors(_Row*_Row_Height))
EndIf
Next
If _Standard_Kernel = 1 And _Row > _Row_Start ; Draws a thin line on top of row if not drawing on top row.
Box(30, (_Row*_Row_Height*_Row_Scale), 480, 2, colorBG)
EndIf
Next
EndIf
If _Standard_Kernel = 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
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
_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
_Standard_Kernel = 0
Select _Drop_Down
Case 0
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
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
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
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
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
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 : _Standard_Kernel = 1 : _Row_Height = 16
Case 6
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 : _Standard_Kernel = 2 : _Row_Height = 16
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
Case #Button_Pen To #Button_Text
For _Loop = #Button_Pen To #Button_Text
SetGadgetState(_Loop, 0)
Next
SetGadgetState(_Which_Gadget, 1)
_Draw_Mode = _Which_Gadget
;- undo
Case #Button_Undo;, #Button_Redo
For i=0 To 40
For j=0 To 220
_Playfield_Pixels(i,j) = undo()\playfield(i,j)
Next
Next
For j=0 To 220
_Playfield_Foreground_Colors(j) = undo()\foreground(j)
_Playfield_Foreground_Colors(j) = undo()\background(j)
Next
DrawPlayfield()
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````````````
;- 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: Undo.
;
ButtonGadget(#Button_Undo, GadgetX(#Button_Clear)+0.5*GadgetWidth(#Canvas_Playfield)-62, GadgetY(#Button_Clear), 60, 30, "Undo")
DisableGadget(#Button_Undo, #True)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Redo.
;
ButtonGadget(#Button_Redo, GadgetX(#Button_Undo)+64, GadgetY(#Button_Undo), 60, 30, "Redo")
DisableGadget(#Button_Redo, #True)
;```````````````````````````````````````````````````````````````````````
; 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, 235, 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")
SetGadgetState(#Row_Mode_Dropdown_Menu, 1)
;```````````````````````````````````````````````````````````````````````
; TEXT: Editing mode.
;
TextGadget(#Text_for_Editing_Mode, GadgetX(#Text_for_Row_Mode), GadgetY(#Row_Mode_Dropdown_Menu)+25+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, 75, 30,
"Draw", #PB_Button_Toggle )
;```````````````````````````````````````````````````````````````````````
; BUTTON: Erase playfield pixel.
;
ButtonGadget(#Button_Erase, GadgetX(#Text_for_Row_Mode)+80, GadgetY(#Text_for_Editing_Mode)+fontUiNormalSize+_Spacer, 75, 30,
"Erase", #PB_Button_Toggle)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Select.
;
ButtonGadget(#Button_Select, GadgetX(#Text_for_Row_Mode)+160, GadgetY(#Text_for_Editing_Mode)+fontUiNormalSize+_Spacer, 75, 30,
"Select", #PB_Button_Toggle )
DisableGadget(#Button_Select, 1)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Cut.
;
ButtonGadget(#Button_Cut, GadgetX(#Button_Draw), GadgetY(#Text_for_Editing_Mode)+fontUiNormalSize+_Spacer+35, 75, 30,
"Cut", #PB_Button_Toggle)
DisableGadget(#Button_Cut, 1)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Copy.
;
ButtonGadget(#Button_Copy, GadgetX(#Button_Draw)+80, GadgetY(#Text_for_Editing_Mode)+fontUiNormalSize+_Spacer+35, 75, 30,
"Copy", #PB_Button_Toggle)
DisableGadget(#Button_Copy, 1)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Paste.
;
ButtonGadget(#Button_Paste, GadgetX(#Button_Draw)+160, GadgetY(#Text_for_Editing_Mode)+fontUiNormalSize+_Spacer+35, 75, 30,
"Paste", #PB_Button_Toggle)
DisableGadget(#Button_Paste, 1)
;```````````````````````````````````````````````````````````````````````
; TEXT: Drawing mode.
;
TextGadget(#Text_for_Drawing_Mode, GadgetX(#Text_for_Row_Mode), GadgetY(#Button_Cut)+25+3*_Spacer, 240, fontUiNormalSize, "Drawing Mode")
SetGadgetFont(#Text_for_Drawing_Mode, FontID(#Font_UiNormal))
SetGadgetColor(#Text_for_Drawing_Mode, #PB_Gadget_FrontColor, _Text_Color)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Pen.
;
ButtonGadget(#Button_Pen, GadgetX(#Text_for_Row_Mode), GadgetY(#Text_for_Drawing_Mode)+fontUiNormalSize+_Spacer, 75, 30,
"Pen", #PB_Button_Toggle )
SetGadgetState(#Button_Pen, 1)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Line.
;
ButtonGadget(#Button_Line, GadgetX(#Button_Pen)+80, GadgetY(#Button_Pen), 75, 30, "Line", #PB_Button_Toggle )
DisableGadget(#Button_Line, 1)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Box.
;
ButtonGadget(#Button_Box, GadgetX(#Button_Line)+80, GadgetY(#Button_Line), 75, 30, "Box", #PB_Button_Toggle )
DisableGadget(#Button_Box, 1)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Ellipse.
;
ButtonGadget(#Button_Ellipse, GadgetX(#Button_Pen), GadgetY(#Button_Pen)+35, 75, 30, "Ellipse", #PB_Button_Toggle )
DisableGadget(#Button_Ellipse, 1)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Text.
;
ButtonGadget(#Button_Text, GadgetX(#Button_Ellipse)+80, GadgetY(#Button_Ellipse), 75, 30, "Text", #PB_Button_Toggle )
DisableGadget(#Button_Text, 1)
;```````````````````````````````````````````````````````````````````````
; TEXT: Coloring mode.
;
TextGadget(#Text_for_Coloring_mode, GadgetX(#Text_for_Row_Mode), GadgetY(#Button_Ellipse)+25+3*_Spacer, 240, fontUiNormalSize, "Coloring Mode")
SetGadgetFont(#Text_for_Coloring_mode, FontID(#Font_UiNormal))
SetGadgetColor(#Text_for_Coloring_mode, #PB_Gadget_FrontColor, _Text_Color)
;```````````````````````````````````````````````````````````````````````
; BUTTON: Paint FG row.
;
ButtonGadget(#Button_Paint_FG_Row, GadgetX(#Text_for_Row_Mode), GadgetY(#Text_for_Coloring_mode)+fontUiNormalSize+_Spacer, 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_Coloring_mode)+fontUiNormalSize+_Spacer, 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)+20+3*_Spacer, 90, fontUiNormalSize, "Color: FG")
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, 50, 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(#Foreground_Color_Box)+GadgetWidth(#Foreground_Color_Box)+10,
GadgetY(#Text_for_Foreground_Color), 30, fontUiNormalSize, "BG")
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, 50, 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_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(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