-
Notifications
You must be signed in to change notification settings - Fork 2
/
menus.asm
753 lines (624 loc) · 17.1 KB
/
menus.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
*=* "Menus"
/*
Read the keyboard and process the key presses
*/
ReadKeyboard:
jsr Keyboard
bcc !processkey+
rts
!processkey:
sta currentkey
cpx #$02
bne !next+
jmp HandleReturnKey
!next:
cpx #$01
bne !next+
jmp HandleDeleteKey
!next:
cmp #KEY_A
bne !next+
jmp HandleAKey
!next:
cmp #KEY_B
bne !next+
jmp HandleBKey
!next:
cmp #KEY_C
bne !next+
jmp HandleCKey
!next:
cmp #KEY_D
bne !next+
jmp HandleDKey
!next:
cmp #KEY_E
bne !next+
jmp HandleEKey
!next:
cmp #KEY_F
bne !next+
jmp HandleFKey
!next:
cmp #KEY_G
bne !next+
jmp HandleGKey
!next:
cmp #KEY_H
bne !next+
jmp HandleHKey
!next:
cmp #KEY_M
bne !next+
jmp HandleMKey
!next:
cmp #KEY_N
bne !next+
jmp HandleNKey
!next:
cmp #KEY_P
bne !next+
jmp HandlePKey
!next:
cmp #KEY_Q
bne !next+
jmp HandleQKey
!next:
cmp #KEY_Y
bne !next+
jmp HandleYKey
!next:
cmp #KEY_Z
bne !next+
jmp HandleZKey
!next:
cmp #KEY_1
bne !next+
jmp Handle1Key
!next:
cmp #KEY_2
bne !next+
jmp Handle2Key
!next:
cmp #KEY_3
bne !next+
jmp Handle3Key
!next:
cmp #KEY_4
bne !next+
jmp Handle4Key
!next:
cmp #KEY_5
bne !next+
jmp Handle5Key
!next:
cmp #KEY_6
bne !next+
jmp Handle6Key
!next:
cmp #KEY_7
bne !next+
jmp Handle7Key
!next:
cmp #KEY_8
bne !next+
jmp Handle8Key
!next:
rts
/*
The A key is used to display the About menu or as column select during the game
*/
HandleAKey:
lda currentmenu
cmp #MENU_MAIN
beq !showabout+
cmp #MENU_ABOUT_SHOWING
beq !hideabout+
!columnselect:
jmp HandleColumnSelection
!showabout:
jmp ShowAboutMenu
!hideabout:
jmp HideAboutMenu
/*
The B key is used to go backwards in the menus as well as column select during the game
*/
HandleBKey:
lda currentmenu
cmp #MENU_PLAYER_SELECT
beq !start+
cmp #MENU_LEVEL_SELECT
beq !playerselect+
cmp #MENU_COLOR_SELECT
beq !levelselect+
!columnselect:
jmp HandleColumnSelection
!levelselect:
jne numplayers:#ONE_PLAYER:!playerselect+
jmp LevelSelectMenu
!start:
jmp StartMenu
!playerselect:
jmp PlayerSelectMenu
HandleCKey:
HandleDKey:
jmp HandleColumnSelection
/*
The E key is used as column select during the game, or the Easy level menu selection
*/
HandleEKey:
jeq currentmenu:#MENU_LEVEL_SELECT:!easy+
!columnselect:
jmp HandleColumnSelection
!easy:
stb #LEVEL_EASY:difficulty
jmp ColorSelectMenu
HandleFKey:
HandleGKey:
jmp HandleColumnSelection
/*
The H key is used as column select during the game, or the Hard level menu selection
*/
HandleHKey:
jeq currentmenu:#MENU_LEVEL_SELECT:!hard+
!columnselect:
jmp HandleColumnSelection
!hard:
stb #LEVEL_HARD:difficulty
jmp ColorSelectMenu
/*
The M key is used to select medium difficulty
*/
HandleMKey:
lda currentmenu
cmp #MENU_LEVEL_SELECT
beq !medium+
rts
!medium:
stb #LEVEL_MEDIUM:difficulty
jmp ColorSelectMenu
/*
Handle the pressing of the N key. This is normally tied to the Quit option
*/
HandleNKey:
jne currentmenu:#MENU_QUIT:!exit+
jsr StartMenu
!exit:
rts
/*
Handle the pressing of the P key.
*/
HandlePKey:
jne currentmenu:#MENU_MAIN:!exit+
jsr PlayerSelectMenu
!exit:
rts
/*
Handle the pressing of the Q key. This is normally tied to the Quit option from the main menu
*/
HandleQKey:
jne currentmenu:#MENU_MAIN:!exit+
jsr QuitMenu
!exit:
rts
/*
Handle the pressing of the Y key. This normally tied to the Quit option
*/
HandleYKey:
jne currentmenu:#MENU_QUIT:!exit+
jsr DisableSprites
stb #$37:$01
jsr $fce2
!exit:
rts
/*
Handle the pressing of the Z key. This is used to forfeit an in-progress game.
*/
HandleZKey:
jne currentmenu:#MENU_GAME:!exit+
//clf playclockrunning // Stop the clock temporarily
//clf showcursor // Disable the cursor
//jsr ForfeitMenu
!exit:
rts
/*
The 1 key serves a few purposes: player selection, color selection and row selection during gameplay
*/
Handle1Key:
lda currentmenu
cmp #MENU_PLAYER_SELECT
beq !playerselect+
cmp #MENU_COLOR_SELECT
beq !colorselect+
cmp #MENU_GAME
beq !rowselect+
rts
!playerselect:
stb #ONE_PLAYER:numplayers
jmp LevelSelectMenu
!colorselect:
stb #BLACK:player1color
jmp StartGame
!rowselect:
jmp HandleRowSelection
/*
The 2 key serves a few purposes: player selection, color selection and row selection during gameplay
*/
Handle2Key:
lda currentmenu
cmp #MENU_PLAYER_SELECT
beq !playerselect+
cmp #MENU_COLOR_SELECT
beq !colorselect+
cmp #MENU_GAME
beq !rowselect+
rts
!playerselect:
stb #TWO_PLAYERS:numplayers
jmp ColorSelectMenu
!colorselect:
stb #WHITE:player1color
jmp StartGame
!rowselect:
jmp HandleRowSelection
Handle3Key:
Handle4Key:
Handle5Key:
Handle6Key:
Handle7Key:
Handle8Key:
jmp HandleRowSelection
/*
Handle the pressing of the return key. This key gets pressed when
the player has typed in the entire movefrom or moveto coordinates
*/
HandleReturnKey:
jne currentmenu:#MENU_GAME:!exit+
bfs processreturn:!exit+
bfc showcursor:!exit+
sef processreturn // Set the flag indicating that we're already processing
// a press of the return key.
bfs movefromisvalid:!validateto+
bfs movetoisvalid:!movepiece+
!validatefrom:
bfs movefromindex:!endreturn+
jsr ValidateFrom // Make sure this is a valid move
jmp !endreturn+
!validateto:
bfs movetoindex:!endreturn+
jsr ValidateTo
bfc movetoisvalid:!endreturn+
!movepiece:
jsr MovePiece
jsr ChangePlayers
!endreturn:
clf processreturn // Clear the return processing flag
!exit:
rts
/*
Allow the user to correct their input
*/
HandleDeleteKey:
ldy cursorxpos // Is the cursor at the beginning of input?
cpy #$00
beq !exit+ // Yea. just exit since we can't delete anymore.
stb #$20:(inputlocationvector),y
dec cursorxpos
!exit:
rts
/*
Deal with a row selection. This is the second part of the board coordinate.
*/
HandleRowSelection:
jeq cursorxpos:#$00:!exit+
lda currentkey
sec
sbc #$31 // Store the row 0 based instead of 1 based.
tay
lda rowlookup, y // Invert the row numbers
pha
jne inputselection:#INPUT_MOVE_FROM:!moveto+
pla
sta movefrom + $01
jsr ComputeMoveFromOffset
jmp !continue+
!moveto:
pla
sta moveto + $01
jsr ComputeMoveToOffset
!continue:
jsr DisplayCoordinate
!exit:
rts
/*
Deal with a column selection. This is the first part of the board coordinate
for movefrom and moveto.
*/
HandleColumnSelection:
jeq cursorxpos:#$01:!exit+
lda currentkey
sec
sbc #$01 // Make the column number 0 based
pha
jne inputselection:#INPUT_MOVE_FROM:!moveto+
pla
sta movefrom
jmp !continue+
!moveto:
pla
sta moveto
!continue:
clc
adc #$41 // Make the column selection uppercase
sta currentkey
jsr DisplayCoordinate
inc cursorxpos // Move the cursor over 1 place
!exit:
rts
/*
Display either the row or the column
*/
DisplayCoordinate:
jsr ClearError
lda currentkey
StoreWord(inputlocationvector, ScreenAddress(CursorPos))
ldy cursorxpos
sta (inputlocationvector), y
rts
/*
The main game loop
*/
StartGame:
jsr ShowGameMenu
!playgame:
jeq numplayers:#TWO_PLAYERS:!twoplayers+
!oneplayer:
jeq currentplayer:player1color:!playersturn+
!computersturn:
jsr ShowThinking
jmp !exit+
!playersturn:
!twoplayers:
jsr DisplayMoveFromPrompt
!exit:
rts
/*
Display the menu that's shown while the game is being played
*/
ShowGameMenu:
jsr ClearMenus
SetMenu(MENU_GAME)
jsr ShowStatus
jsr UpdateCurrentPlayer
jsr UpdateCaptureCounts
jsr ShowCaptured
jsr UpdateCaptureCounts
jsr CheckKingInCheck
jsr ShowKingInCheck
CopyMemory(ForfeitStart, ScreenAddress(ForfeitPos), ForfeitEnd - ForfeitStart)
FillMemory(ColorAddress(ForfeitPos), ForfeitEnd - ForfeitStart, WHITE)
rts
/*
Show the status line under the title and copyright. It includes which player is currently playing
as well as a play clock for that player.
*/
ShowStatus:
CopyMemory(TurnStart, ScreenAddress(TurnPos), TurnEnd - TurnStart)
FillMemory(ColorAddress(TurnPos), TurnEnd - TurnStart, WHITE)
CopyMemory(TimeStart, ScreenAddress(TimePos), TimeEnd - TimeStart)
FillMemory(ColorAddress(TimePos), TimeEnd - TimeStart, WHITE)
FillMemory(ScreenAddress(StatusSepPos), $0e, $77)
FillMemory(ColorAddress(StatusSepPos), $0e, WHITE)
rts
/*
Show the portion of the screen that details which pieces have been captured by the current player
*/
ShowCaptured:
CopyMemory(CapturedStart, ScreenAddress(CapturedPos), CapturedEnd - CapturedStart)
FillMemory(ColorAddress(CapturedPos), CapturedEnd - CapturedStart, WHITE)
CopyMemory(CapturedUnderlineStart, ScreenAddress(CapturedUnderlinePos), CapturedUnderlineEnd - CapturedUnderlineStart)
FillMemory(ColorAddress(CapturedUnderlinePos), CapturedUnderlineEnd - CapturedUnderlineStart, WHITE)
CopyMemory(CapturedPawnStart, ScreenAddress(CapturedPawnPos), CapturedPawnEnd - CapturedPawnStart)
FillMemory(ColorAddress(CapturedPawnPos), CapturedPawnEnd - CapturedPawnStart, WHITE)
CopyMemory(CapturedKnightStart, ScreenAddress(CapturedKnightPos), CapturedKnightEnd - CapturedKnightStart)
FillMemory(ColorAddress(CapturedKnightPos), CapturedKnightEnd - CapturedKnightStart, WHITE)
CopyMemory(CapturedBishopStart, ScreenAddress(CapturedBishopPos), CapturedBishopEnd - CapturedBishopStart)
FillMemory(ColorAddress(CapturedBishopPos), CapturedBishopEnd - CapturedBishopStart, WHITE)
CopyMemory(CapturedRookStart, ScreenAddress(CapturedRookPos), CapturedRookEnd - CapturedRookStart)
FillMemory(ColorAddress(CapturedRookPos), CapturedRookEnd - CapturedRookStart, WHITE)
CopyMemory(CapturedQueenStart, ScreenAddress(CapturedQueenPos), CapturedQueenEnd - CapturedQueenStart)
FillMemory(ColorAddress(CapturedQueenPos), CapturedQueenEnd - CapturedQueenStart, WHITE)
rts
/*
Clear the menu options and any displayed questions
TODO: This could probably be simplified with routine to clear the right side of the screen
*/
ClearMenus:
FillMemory(ColorAddress(Empty1Pos), $0e, BLACK)
FillMemory(ColorAddress(Empty2Pos), $0e, BLACK)
FillMemory(ColorAddress(Empty3Pos), $0e, BLACK)
FillMemory(ColorAddress(Empty4Pos), $0e, BLACK)
FillMemory(ColorAddress(EmptyQuestionPos), $0e, BLACK)
rts
/*
Show the Start menu and the available options
*/
StartMenu:
jsr ClearMenus
SetMenu(MENU_MAIN)
// Display the Play Game menu option
CopyMemory(PlayStart, ScreenAddress(PlayGamePos), PlayEnd - PlayStart)
FillMemory(ColorAddress(PlayGamePos), PlayEnd - PlayStart, WHITE)
// Display the About menu option
CopyMemory(AboutStart, ScreenAddress(AboutPos), AboutEnd - AboutStart)
FillMemory(ColorAddress(AboutPos), AboutEnd - AboutStart, WHITE)
// Display the Quit Game menu option
CopyMemory(QuitStart, ScreenAddress(QuitGamePos), QuitEnd - QuitStart)
FillMemory(ColorAddress(QuitGamePos), QuitEnd - QuitStart, WHITE)
rts
/*
Show the Forfeit confirmation and available options
*/
ForfeitMenu:
jsr ClearMenus
SetMenu(MENU_FORFEIT)
CopyMemory(ForfeitConfirmationStart, ScreenAddress(ForfeitConfirmPos), ForfeitConfirmationEnd - ForfeitConfirmationEnd)
FillMemory(ColorAddress(ForfeitConfirmPos), ForfeitConfirmationEnd - ForfeitConfirmationStart, WHITE)
jmp ShowYesNoOptions
/*
Show the Quit menu and the available options
*/
QuitMenu:
jsr ClearMenus
SetMenu(MENU_QUIT)
// Display Quit message
CopyMemory(QuitConfirmationStart, ScreenAddress(QuitConfirmPos), QuitConfirmationEnd - QuitConfirmationStart)
FillMemory(ColorAddress(QuitConfirmPos), QuitConfirmationEnd - QuitConfirmationStart, WHITE)
jmp ShowYesNoOptions
ShowYesNoOptions:
// Yes option
CopyMemory(YesStart, ScreenAddress(YesPos), YesEnd - YesStart)
FillMemory(ColorAddress(YesPos), YesEnd - YesStart, WHITE)
// No option
CopyMemory(NoStart, ScreenAddress(NoPos), NoEnd - NoStart)
FillMemory(ColorAddress(NoPos), NoEnd - NoStart, WHITE)
rts
PlayerSelectMenu:
jsr ClearMenus
SetMenu(MENU_PLAYER_SELECT)
// Display the Player Selection message
CopyMemory(PlayerSelectStart, ScreenAddress(PlayerSelectPos), PlayerSelectEnd - PlayerSelectStart)
FillMemory(ColorAddress(PlayerSelectPos), PlayerSelectEnd - PlayerSelectStart, WHITE)
// 1 player option
CopyMemory(OnePlayerStart, ScreenAddress(OnePlayerPos), OnePlayerEnd - OnePlayerStart)
FillMemory(ColorAddress(OnePlayerPos), OnePlayerEnd - OnePlayerStart, WHITE)
// 2 player option
CopyMemory(TwoPlayerStart, ScreenAddress(TwoPlayerPos), TwoPlayerEnd - TwoPlayerStart)
FillMemory(ColorAddress(TwoPlayerPos), TwoPlayerEnd - TwoPlayerStart, WHITE)
jmp ShowBackMenuItem
/*
Level selection menu
*/
LevelSelectMenu:
jsr ClearMenus
SetMenu(MENU_LEVEL_SELECT)
CopyMemory(LevelSelectStart, ScreenAddress(LevelSelectPos), LevelSelectEnd - LevelSelectStart)
FillMemory(ColorAddress(LevelSelectPos), LevelSelectEnd - LevelSelectStart, WHITE)
// Easy menu option
CopyMemory(LevelEasyStart, ScreenAddress(EasyPos), LevelEasyEnd - LevelEasyStart)
FillMemory(ColorAddress(EasyPos), LevelEasyEnd - LevelEasyStart, WHITE)
// Medium menu option
CopyMemory(LevelMediumStart, ScreenAddress(MediumPos), LevelMediumEnd - LevelMediumStart)
FillMemory(ColorAddress(MediumPos), LevelMediumEnd - LevelMediumStart, WHITE)
// Hard menu option
CopyMemory(LevelHardStart, ScreenAddress(HardPos), LevelHardEnd - LevelHardStart)
FillMemory(ColorAddress(HardPos), LevelHardEnd - LevelHardStart, WHITE)
jmp ShowBackMenuItem
/*
Color selection menu
*/
ColorSelectMenu:
jsr ClearMenus
SetMenu(MENU_COLOR_SELECT)
// Color select message
CopyMemory(Player1ColorStart, ScreenAddress(ColorSelectPos), Player1ColorEnd - Player1ColorStart)
FillMemory(ColorAddress(ColorSelectPos), Player1ColorEnd - Player1ColorStart, WHITE)
// Black menu item
CopyMemory(BlackMenuStart, ScreenAddress(BlackPos), BlackMenuEnd - BlackMenuStart)
FillMemory(ColorAddress(BlackPos), BlackMenuEnd - BlackMenuStart, WHITE)
// White menu item
CopyMemory(WhiteMenuStart, ScreenAddress(WhitePos), WhiteMenuEnd - WhiteMenuStart)
FillMemory(ColorAddress(WhitePos), WhiteMenuEnd - WhiteMenuStart, WHITE)
jmp ShowBackMenuItem
/*
Display the menu item to allow navigating backwards
*/
ShowBackMenuItem:
CopyMemory(BackMenuStart, ScreenAddress(BackMenuPos), BackMenuEnd - BackMenuStart)
FillMemory(ColorAddress(BackMenuPos), BackMenuEnd - BackMenuStart, WHITE)
rts
/*
Show the About menu
*/
ShowAboutMenu:
// Buffer the center portion of the screen
CopyMemory(ScreenAddress(AboutTextPos), screenbuffer, AboutTextEnd - AboutTextStart)
CopyMemory(ColorAddress(AboutTextPos), colorbuffer, AboutTextEnd - AboutTextStart)
CopyMemory(AboutTextStart, ScreenAddress(AboutTextPos), AboutTextEnd - AboutTextStart)
CopyMemory(AboutTextColorStart, ColorAddress(AboutTextPos), AboutTextColorEnd - AboutTextColorStart)
SetMenu(MENU_ABOUT_SHOWING)
rts
/*
Remove the about menu
*/
HideAboutMenu:
// Load the buffer back
CopyMemory(colorbuffer, ColorAddress(AboutTextPos), AboutTextEnd - AboutTextStart)
CopyMemory(screenbuffer, ScreenAddress(AboutTextPos), AboutTextEnd - AboutTextStart)
SetMenu(MENU_MAIN)
rts
/*
Display the prompt to allow the player to enter the coordinates of the piece to move.
*/
DisplayMoveFromPrompt:
CopyMemory(MoveFromStart, ScreenAddress(MovePos), MoveFromEnd - MoveFromStart)
FillMemory(ColorAddress(MovePos), MoveFromEnd - MoveFromStart, WHITE)
SetInputSelection(INPUT_MOVE_FROM)
jsr ResetInput
Enable(showcursor)
rts
/*
Display the prompt to allow the player to enter the coordinates of where to move the
selected piece.
*/
DisplayMoveToPrompt:
CopyMemory(MoveToStart, ScreenAddress(MovePos), MoveToEnd - MoveToStart)
FillMemory(ColorAddress(MovePos), MoveToEnd - MoveToStart, WHITE)
SetInputSelection(INPUT_MOVE_TO)
jsr ResetInput
rts
/*
If the current player's king is in check, display a helpful message
*/
ShowKingInCheck:
jeq currentplayer:#WHITES_TURN:!white+
!black:
ldx #BLACK
jmp !continue+
!white:
ldx #WHITE
!continue:
jne incheckflags, x:#ENABLE:!exit+
CopyMemory(KingInCheckStart, ScreenAddress(KingInCheckPos), KingInCheckEnd - KingInCheckStart)
FillMemory(ColorAddress(KingInCheckPos), KingInCheckEnd - KingInCheckStart, WHITE)
!exit:
rts
/*
Figure out whose turn it is and update the status lines.
*/
UpdateCurrentPlayer:
stb #$3c:subseconds // Reset subsecond count
jeq numplayers:#ONE_PLAYER:!oneplayer+
!twoplayers:
stb #WHITE:ColorAddress(PlayerNumberPos)
jeq player1color:currentplayer:!playeronesturn+
!playertwosturn:
stb #'2':ScreenAddress(PlayerNumberPos)
jmp !playersturn+
!playeronesturn:
stb #'1':ScreenAddress(PlayerNumberPos)
jmp !playersturn+
!oneplayer:
stb #BLACK:ColorAddress(PlayerNumberPos)
jeq player1color:currentplayer:!playersturn+
!computersturn:
CopyMemory(ComputerStart, ScreenAddress(TurnValuePos), ComputerEnd - ComputerStart)
FillMemory(ColorAddress(TurnValuePos), ComputerEnd - ComputerStart, WHITE)
jsr ShowThinking // Enable the spinner to show that the computer is thinking
jmp !return+
!playersturn:
CopyMemory(PlayerStart, ScreenAddress(TurnValuePos), PlayerEnd - PlayerStart)
FillMemory(ColorAddress(TurnValuePos), PlayerEnd - PlayerStart, WHITE)
jsr HideThinking // If it's the players turn, disable the spinner
!return:
rts