-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtictactoe.asm
More file actions
1189 lines (1129 loc) · 25.7 KB
/
tictactoe.asm
File metadata and controls
1189 lines (1129 loc) · 25.7 KB
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
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;============================= iNES header identifier =============================
.inesprg 1 ; 1x 16KB PRG code
.ineschr 1 ; 1x 8KB CHR data
.inesmap 0 ; Mapper 0 = NROM, no bank swapping
.inesmir 0 ; BCG Horizontal Mirroring
;============================= Constants =============================
BPM = 90
BPMBLINK = 3600/(BPM*2) ; bpm blink choose (3600/(BPM*2)), exemple (3600/180) equal 90 bpm blink choose.
SPEEDREADINPUT = 10 ; frames to cooldown control input
;============================= PPU Registers =============================
PPUCTRL = $2000 ; Controller
PPUMASK = $2001 ; Mask
PPUSTATUS = $2002 ; Status
OAMADDR = $2003 ; OAM address
OAMDATA = $2004 ; OAM data
PPUSCROLL = $2005 ; Scroll
PPUADDR = $2006 ; PPU Address
PPUDATA = $2007 ; PPU Data
OAMDMA = $4014 ; OAM DMA
;============================= APU Registers =============================
; Pulse Channel 1
PULSE1CTRL = $4000 ; Pulse 1 Control
PULSE1RMPCTRL = $4001 ; Pulse 1 Ramp Control
PULSE1LFT = $4002 ; Pulse 1 Low bit Frequency
PULSE1HFT = $4003 ; Pulse 1 High bit Frequency
; Pulse Channel 2
PULSE2CTRL = $4004 ; Pulse 2 Control
PULSE2RMPCTRL = $4005 ; Pulse 2 Ramp Control
PULSE2LFT = $4006 ; Pulse 2 Low bit Frequency
PULSE2HFT = $4007 ; Pulse 2 High bit Frequency
; DMC Channel
DMCIRQ = $4010 ; DMC IRQ Enable
; Others Uses
APUCTRL = $4015 ; Control and Status
APUFRMC = $4017 ; APU Frame Counter
;============================= variables =============================
; Variables (NES Internal RAM)
; ---> Zero Page used here ! $00--$FF (256 Bytes Free RAM) <---
.zp
framesToBlink .ds 1 ; Number of Frames to Toggle Blink (framesToBlink = #BPMBLINK)
coolDownInput .ds 1 ; Number of Frames Input Cooldown (coolDownInput = #SPEEDREADINPUT)
inputControl .ds 2 ; Control Press by Player 0 and 1 (MSB-LSB)==>(A,B,SCL,STRT,UP,DOWN,LEFT,RIGHT)
moveDirPonter .ds 2 ; Pointer use for repeat same move (LSB,MSB) (Big Endian)
simbols .ds 9 ; vector contaim tile of ever positon of table game
turn .ds 1 ; turn of P0 = 1, P1 = 2, Over = 3
lastGameTurn .ds 1 ; turn of P0 = 1, P1 = 2
choose .ds 1 ; Blank Position for next player start option
winner .ds 1 ; Winner P0 = 1, P1 = 2, Drawn = 3
mutexNMIClear .ds 1 ; Mutex to synchronize NMI
flagBGChange .ds 1 ; Flag indicator BG change
flagSpriteChange .ds 1 ; Flag indicator Sprite change
; RAM section ($0200-$07FF):
.bss
BufferDMA .ds 256 ; DMA Buffer $0200 -- $02FF (256 Bytes / 64 Sprites)
;============================= Code Segment =============================
.code
; Start bank code (CPU $8000-$BFFF) Mirrored to (CPU $C000-$FFFF)
.bank 0
.org $8000
;============================= Non Maskable Interrupt =============================
; Vblank generated a NMI(Non Maskable Interrupt), this period is used to
; modify sprites data and PPU VRAM.
;===================================================================
NMI:
; Save Registers in Possible Race Condition
pha
tya
pha
txa
pha
; Call DMA-Sprite
lda #high(BufferDMA)
sta OAMDMA
; Check if there was a shift change using Sync Flag
lda <flagBGChange
bne noTurnChange
; Indicates synchronization that has already consumed the turn change
inc <flagBGChange
; Print string of turn player
jsr PrintTurnPlayer
noTurnChange:
lda #$00
; is not zero, the process of starting sprite evaluation triggers
; an OAM hardware refresh bug that causes the 8 bytes beginning
; at OAMADDR & $F8 to be copied and replace the first 8 bytes of OAM.
sta OAMADDR
bit PPUSTATUS
; The PPU scroll registers share internal state with the PPU address registers.
; Because of this, PPUSCROLL and the nametable bits in PPUCTRL should be written
; after any writes to PPUADDR.
; No Scroll Screen
sta PPUSCROLL
sta PPUSCROLL
; Enable NMI in VBlank
lda #%10001000
sta PPUCTRL
; Free Mutex
inc <mutexNMIClear
; Restore Registers in Possible Race Condition
pla
tax
pla
tay
pla
; End of NMI
rti
;============================= Enter Point CPU =============================
; Boot game, this is enter point of CPU (start of code game)
;===================================================================
Boot:
; Ignore IRQs
sei
cld
; Disable sound
ldx #$40
stx APUFRMC ; Set IRQ APU Flag
; Set Stack Ponter
ldx #$FF
txs
txa ; x==$FF --> a:=x
inx
; Safe Code for Resets -- PPU disabled
stx PPUMASK
stx PPUCTRL
stx DMCIRQ ; disable DMC IRQs
; Race condition
; The vblank flag is in an unknown state after reset,
; so it is cleared here to make sure that WaitVblank1:
; does not exit immediately.
bit PPUSTATUS
WaitVblank1:
bit PPUSTATUS
bpl WaitVblank1
; Clear Memory Inside NES ($0000-$07FF) Mirrored to ($0800-$1FFF) (Only Used in Game)
ldy #$00
ClearMemory:
sty <$00,x ; zero page
sta BufferDMA,x ; OAM Buffer RAM
inx
bne ClearMemory
; Waint again for complete frame
WaitVblank2:
bit PPUSTATUS
bpl WaitVblank2
;============================= Set Variables =============================
lda #$01
sta <turn ; Player 1 ever start
sta <lastGameTurn
lda #$03
sta <winner ; Assuming a possible tie
;===================================================================
; Load Sprites Palettes colors, and BackGrid (Grid Table)
jsr LoadPalettes
jsr LoadSprites
jsr LoadATtable
jsr PrintGrid
; Start in Center Position
lda #$04
sta choose
; Load DMA for input sprites inside VRAM (OAM Primary Memory)
lda #high(BufferDMA)
sta OAMDMA
; Enable APU
lda #%00000011
sta APUCTRL
; Pulse Channel Control Setup
lda #%10011111
sta PULSE1CTRL
sta PULSE2CTRL
; No Scroll Screen
lda #$00
bit PPUSTATUS
sta PPUSCROLL
sta PPUSCROLL
; Enable Rendering Sprites and Backgrounds
lda #%00011110
sta PPUMASK
; Enable NMI in VBlank
lda #%10001000
sta PPUCTRL
; Forever loop, Logic game, waint for a Vblank and NMI call
ForeverLoop:
; Mutex to synchronize data change after NMI
lda <mutexNMIClear
waitNMIMutex:
cmp <mutexNMIClear
beq waitNMIMutex
; Get Input Control Players
jsr GetInputControl
lda <turn
cmp #$03
bne noEndGame
; Reset game after some winner
jsr ResetEndGame
jmp jmpEndGame
noEndGame:
; Blink the selected position to play
jsr BlinkChoose
; Move "cursor" in screen by input control
jsr MoveChoosePlayer
; Select choose
jsr SetChoosePlayer
jmpEndGame:
lda <flagSpriteChange
beq noChangeSprites
dec <flagSpriteChange
; Update Sprites (Blink, Position set, Game over, etc..)
jsr UpdateSprites
noChangeSprites:
; Increment Count Frame and Decrement coolDownInput
jsr ChangeCounts
jmp ForeverLoop
;===================================================================
; Load Palettes colors
;
LoadPalettes:
bit PPUSTATUS
lda #$3F
sta PPUADDR
lda #$00
sta PPUADDR
ldy #$08
nextPalette:
ldx #$04
loopPalettes:
lda Palettes-1,x
sta PPUDATA
dex
bne loopPalettes
dey
bne nextPalette
rts
;===================================================================
; Load Sprites
;
LoadSprites:
ldx #(EndSprites-Sprites)
loopSprites:
lda Sprites-1,x
sta BufferDMA-1,x
dex
bne loopSprites
rts
;===================================================================
; Read Control Players
;
GetInputControl:
lda #$01
sta $4016
sta <inputControl+1
lsr a
sta $4016
loopReadControl:
lda $4016
and #$03
cmp #$01
rol <inputControl
lda $4017
and #$03
cmp #$01
rol <inputControl+1
bcc loopReadControl
rts
;===================================================================
; Update Sprites (Modify DMA zone $0200-$02FF)
;
UpdateSprites:
ldy #$80
ldx #$09
loopPrint:
lda <simbols-1,x
sta BufferDMA+1,y
sta BufferDMA+5,y
sta BufferDMA+9,y
sta BufferDMA+13,y
tya
sec
sbc #$10
tay
dex
bne loopPrint
rts
;===================================================================
; Get first position Clear, count by rows and coluns
;
AnyValidPosition:
ldx #$00
loopFirstClear:
lda <simbols,x
beq found
inx
cpx #$09
bne loopFirstClear
lda #$03
sta <turn
found:
stx <choose
rts
;===================================================================
; Decrement Frame Counters
;
ChangeCounts:
lda <framesToBlink
beq noDecBlink
dec <framesToBlink
noDecBlink:
lda <coolDownInput
beq noDecInput
dec <coolDownInput
noDecInput:
rts
;===================================================================
; blink sprite select position player (select position)
;
BlinkChoose:
lda <choose
cmp #$09
beq outBlinkChoose
lda <framesToBlink
bne outBlinkChoose
lda #BPMBLINK
sta <framesToBlink
ldx <choose
lda <simbols,x
eor <turn
sta <simbols,x
; Flag to Change Sprites enable
inc <flagSpriteChange
outBlinkChoose:
rts
;===================================================================
; Select Choose Player
;
SetChoosePlayer:
lda <coolDownInput
bne outSetChoosePlayer
ldx <turn
lda <inputControl-1,x
and #%10000000
beq outSetChoosePlayer
ldy <choose
lda <turn
sta simbols,y
; Swap Turn
eor #$03
sta <turn
jsr VerifyWinner
; Get new blank position
jsr AnyValidPosition
lda #SPEEDREADINPUT
sta <coolDownInput
; Flag to Change Sprites enable
inc <flagSpriteChange
; Indicates to NMI synchronization that there is a shift change to process
dec <flagBGChange
jmp Play440
outSetChoosePlayer:
rts
;===================================================================
; Move "cursor" do player
;
MoveChoosePlayer:
lda <coolDownInput
bne outChoosePlayer
ldy <choose
cpy #$09
beq outChoosePlayer
ldx <turn
dex
lda <inputControl,x
and #%00001000 ; UP
beq tryDown
lda #low(up)
sta <moveDirPonter
lda #high(up)
sta <moveDirPonter+1
up:
dey
dey
dey
jmp moveChoose
tryDown:
lda <inputControl,x
and #%00000100 ; DOWN
beq tryLeft
lda #low(down)
sta <moveDirPonter
lda #high(down)
sta <moveDirPonter+1
down:
iny
iny
iny
jmp moveChoose
tryLeft:
lda <inputControl,x
and #%00000010 ; LEFT
beq tryRight
lda #low(left)
sta <moveDirPonter
lda #high(left)
sta <moveDirPonter+1
left:
dey
jmp moveChoose
tryRight:
lda <inputControl,x
and #%00000001 ; RIGHT
beq outChoosePlayer
lda #low(right)
sta <moveDirPonter
lda #high(right)
sta <moveDirPonter+1
right:
iny
moveChoose:
cpy #$00
bcc outChoosePlayer
cpy #$09
bcs outChoosePlayer
lda simbols,y
beq validPosition
jmp [moveDirPonter]
validPosition:
ldx <choose
sta <simbols,x
sty <choose
lda #SPEEDREADINPUT
sta <coolDownInput
lda #$00
sta <framesToBlink
; Flag to Change Sprites enable
inc <flagSpriteChange
jmp Play220
outChoosePlayer:
rts
;===================================================================
; Verify end game (winer)
; obs: future optimal code (more generic)
VerifyWinner:
lda <turn
pha
lda <simbols
beq LV2
; line horizon 1
cmp <simbols+1
bne DiagMain
cmp <simbols+2
bne DiagMain
lda #$03
sta <turn
sta <simbols
sta <simbols+1
sta <simbols+2
jmp outVerifyGame
DiagMain: ; diagonal main
cmp <simbols+4
bne LV1
cmp <simbols+8
bne LV1
lda #$03
sta <turn
sta <simbols
sta <simbols+4
sta <simbols+8
jmp outVerifyGame
LV1: ; Line Vertical 1
cmp <simbols+3
bne LV2
cmp <simbols+6
bne LV2
lda #$03
sta <turn
sta <simbols
sta <simbols+3
sta <simbols+6
jmp outVerifyGame
LV2: ; Line Vertical 2
lda <simbols+1
beq LV3
cmp <simbols+4
bne LV3
cmp <simbols+7
bne LV3
lda #$03
sta <turn
sta <simbols+1
sta <simbols+4
sta <simbols+7
jmp outVerifyGame
LV3: ; Line Vertical 2
lda <simbols+2
beq LH2
cmp <simbols+5
bne DiagSec
cmp <simbols+8
bne DiagSec
lda #$03
sta <turn
sta <simbols+2
sta <simbols+5
sta <simbols+8
jmp outVerifyGame
DiagSec: ; Diagonal Secondary
cmp <simbols+4
bne LH2
cmp <simbols+6
bne LH2
lda #$03
sta <turn
sta <simbols+2
sta <simbols+4
sta <simbols+6
jmp outVerifyGame
LH2: ; Line Horizon 2
lda <simbols+3
beq LH3
cmp <simbols+4
bne LH3
cmp <simbols+5
bne LH3
lda #$03
sta <turn
sta <simbols+3
sta <simbols+4
sta <simbols+5
jmp outVerifyGame
LH3: ; Line Horizon 3
lda <simbols+6
beq outVerifyGame
cmp <simbols+7
bne outVerifyGame
cmp <simbols+8
bne outVerifyGame
lda #$03
sta <turn
sta <simbols+6
sta <simbols+7
sta <simbols+8
jmp outVerifyGame
outVerifyGame:
pla
ldx <turn
cpx #$03
bne outWins
; Set a player winner
eor #$03
sta <winner
outWins:
rts
;===================================================================
; Reset Game After Some Winner
;
ResetEndGame:
lda <inputControl
and #%00010000
bne reset
lda <inputControl+1
and #%00010000
beq outResetGame
reset:
lda <lastGameTurn
eor <turn
sta <turn
sta <lastGameTurn
lda #$00
sta <framesToBlink
ldx #$09
loopReset:
dex
sta <simbols,x
bne loopReset
lda #$03
sta <winner
lda #$04
sta choose
; Flag to Change Sprites enable
inc <flagSpriteChange
; Indicates to NMI synchronization that there is a shift change to process
dec <flagBGChange
jmp Play440
outResetGame:
rts
;===================================================================
; Print string turn
;
PrintTurnPlayer:
lda <turn
cmp #$03
beq endGame
bit PPUSTATUS
lda #$20
sta PPUADDR
lda #$A8
sta PPUADDR
lda #$00
sta PPUDATA
ldx #$0C
loopTurn:
lda StringTurn-1,x
sta PPUDATA
dex
bne loopTurn
lda #$16
clc
adc <turn
sta PPUDATA
stx PPUDATA
rts
endGame:
lda <winner
cmp #$03
beq drawn
jmp PrintPlayerWinner
; rts
drawn:
jmp PrintDrawn
; rts
;===================================================================
; Print string Winner
;
PrintPlayerWinner:
bit PPUSTATUS
lda #$20
sta PPUADDR
lda #$A8
sta PPUADDR
ldx #$0E
loopWinner:
lda StringWinner-1,X
sta PPUDATA
dex
bne loopWinner
lda #$16
clc
adc <winner
sta PPUDATA
rts
;===================================================================
; Print string of drawn
;
PrintDrawn:
bit PPUSTATUS
lda #$20
sta PPUADDR
lda #$A9
sta PPUADDR
lda #$00
sta PPUDATA
sta PPUDATA
ldx #$0A
loopDrawn:
lda StringDrawn-1,x
sta PPUDATA
dex
bne loopDrawn
stx PPUDATA
stx PPUDATA
rts
;===================================================================
; Print String Created
;
PrintCreated:
bit PPUSTATUS
lda #$23
sta PPUADDR
lda #$24
sta PPUADDR
lda #$00
sta PPUDATA
sta PPUDATA
ldx #$14
loopCreated:
lda StringCreated-1,x
sta PPUDATA
dex
bne loopCreated
rts
;===================================================================
; Print Grid (BackGround)
;
PrintGrid:
ldx #$0E
ldy #$02
; PPUADDR 32 bytes increment
lda #$04
sta PPUCTRL
bit PPUSTATUS
lda #$21
sta PPUADDR
lda #$0D
sta PPUADDR
lda #$01
loopColuns:
sta PPUDATA
dex
bne loopColuns
lda #$21
sta PPUADDR
lda #$12
sta PPUADDR
lda #$01
ldx #$0E
dey
bne loopColuns
; PPUADDR 1 bytes increment
lda #$00
sta PPUCTRL
ldx #$0E
ldy #$02
lda #$21
sta PPUADDR
lda #$89
sta PPUADDR
lda #$02
loopRows:
sta PPUDATA
dex
bne loopRows
lda #$22
sta PPUADDR
lda #$29
sta PPUADDR
lda #$02
ldx #$0E
dey
bne loopRows
ldx #$03
lda #$21
sta PPUADDR
lda #$8D
sta PPUADDR
stx PPUDATA
lda #$21
sta PPUADDR
lda #$92
sta PPUADDR
stx PPUDATA
lda #$22
sta PPUADDR
lda #$2D
sta PPUADDR
stx PPUDATA
lda #$22
sta PPUADDR
lda #$32
sta PPUADDR
stx PPUDATA
jmp PrintCreated
; rts
;===================================================================
; Load PPU attribute tables with zero (Palette 0)
;
LoadATtable:
bit PPUSTATUS
lda #$20
sta PPUADDR
lda #$00
sta PPUADDR
lda #$00
ldx #$00
ldy #$04
loopClear:
sta PPUDATA
dex
bne loopClear
dey
bne loopClear
rts
;===================================================================
; Sounds game
;
Play220:
lda #%11111011
sta PULSE1LFT
lda #%01001001
sta PULSE1HFT
rts
Play440:
lda #%11111101
sta PULSE2LFT
lda #%01001000
sta PULSE2HFT
rts
;===================================================================
; Print Grid (BackGround)
;
Sprites:
.byte 72,0,%01000000,90
.byte 72,0,%00000000,82
.byte 80,0,%11000000,90
.byte 80,0,%10000000,82
.byte 72,0,%01000000,128
.byte 72,0,%00000000,120
.byte 80,0,%11000000,128
.byte 80,0,%10000000,120
.byte 72,0,%01000000,168
.byte 72,0,%00000000,160
.byte 80,0,%11000000,168
.byte 80,0,%10000000,160
;
.byte 110,0,%01000000,90
.byte 110,0,%00000000,82
.byte 118,0,%11000000,90
.byte 118,0,%10000000,82
.byte 110,0,%01000000,128
.byte 110,0,%00000000,120
.byte 118,0,%11000000,128
.byte 118,0,%10000000,120
.byte 110,0,%01000000,168
.byte 110,0,%00000000,160
.byte 118,0,%11000000,168
.byte 118,0,%10000000,160
;
.byte 150,0,%01000000,90
.byte 150,0,%00000000,82
.byte 158,0,%11000000,90
.byte 158,0,%10000000,82
.byte 150,0,%01000000,128
.byte 150,0,%00000000,120
.byte 158,0,%11000000,128
.byte 158,0,%10000000,120
.byte 150,0,%01000000,168
.byte 150,0,%00000000,160
.byte 158,0,%11000000,168
.byte 158,0,%10000000,160
EndSprites:
; Label used for auto calculate bytes for write in memory := (EndSprites-Sprites) Bytes
;===================================================================
; String msgs
;
StringTurn:
.byte 0,17,8,22,4,12,16,0,14,17,20,19 ; "TURN PLAYER "
StringWinner:
.byte 0,17,8,22,4,12,16,0,17,8,14,14,10,21 ; "WINNER PLAYER "
StringDrawn:
.byte 8,13,4,9,0,14,21,4,17,7 ; "DRAWN GAME"
StringCreated:
.byte 18,19,4,17,15,10,12,20,11,0,22,5,0,7,8,19,4,8,17,6 ; "CREATED BY JULIORATS"
;===================================================================
; Palettes Color data
;
Palettes:
.byte $0F,$0F,$30,$0F
;===================================================================
; Bank of vectors input address memory
;
.bank 1
.org $BFFA
.dw NMI ; Non-Maskable Interrupt (NMI)
.dw Boot ; Enter Point Address Code
;===================================================================
; Bank of CHR memory (VRAM $0000-$1FFF)
;
.bank 2
.org $0000
; Tile 0: Blank
.defchr $00000000,\
$00000000,\
$00000000,\
$00000000,\
$00000000,\
$00000000,\
$00000000,\
$00000000
; Tile 1: Vertical Line
.defchr $00111100,\
$00111100,\
$00111100,\
$00111100,\
$00111100,\
$00111100,\
$00111100,\
$00111100
; Tile 2: Horizontal Line
.defchr $00000000,\
$00000000,\
$11111111,\
$11111111,\
$11111111,\
$11111111,\
$00000000,\
$00000000
; Tile 3: Cross Line
.defchr $00111100,\
$00111100,\
$11111111,\
$11111111,\
$11111111,\
$11111111,\
$00111100,\
$00111100
; Tile 4: A
.defchr $00111000,\
$01101100,\
$11000110,\
$11000110,\
$11111110,\
$11000110,\
$11000110,\
$00000000
; Tile 5: B
.defchr $11111100,\
$11001110,\
$11001110,\
$11111100,\
$11001110,\
$11001110,\
$11111100,\
$00000000
; Tile 6: C
.defchr $01111110,\
$11100000,\
$11100000,\
$11100000,\
$11100000,\
$11100000,\
$01111110,\
$00000000
; Tile 7: D
.defchr $11111000,\
$11001100,\
$11000110,\
$11000110,\
$11000110,\
$11001100,\
$11111000,\
$00000000
; Tile 8: E
.defchr $11111110,\
$11000000,\
$11000000,\
$11111100,\
$11000000,\
$11000000,\
$11111110,\
$00000000
; Tile 9: G
.defchr $00111110,\
$01100000,\
$11000000,\