-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect-4.asm
76 lines (65 loc) · 1.72 KB
/
connect-4.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
!cpu w65c02
;******************************* Boiler plate *********************************
*=$801
!word $080C ; Pointer to next BASIC line
!word $0001 ; Line number $0001 = 1
!byte $9E ; SYS BASIC token
!pet " $810",0 ; Address where ASM starts
!word $0000 ; EOF BASIC program
*=$810
;********************************Inclusions************************************
!src "cx16stuff/cx16.inc"
!src "cx16stuff/vera0.9.inc"
!src "bin2vera.inc"
!src "TextUI.inc"
!src "winscenarios.inc"
!src "timer.inc"
jmp main
!src "globals.inc"
;***********************************Main***************************************
main ;Where things before the IRQ handler is run
jsr Init_VERA
jsr Load_bins
jsr Reset
Init_IRQ:
lda IRQVec
sta default_irq_vector
lda IRQVec+1
sta default_irq_vector+1 ;Save current IRQ Vector to new memory address
sei ;Stop interrupts while replacing Vector
lda #<Custom_IRQ
sta IRQVec
lda #>Custom_IRQ
sta IRQVec+1
lda #$01 ;Make VERA only set IRQ at VSync
sta VERA_IEN
cli ;Enable interrupts now Custom Vector is set.
@Main_loop: ;Called at every vsync
wai ;Wait for IRQ PROBLEM ATM!!
lda Vsync_enabled
beq @Main_loop ;If not vsync then wait for vsync
jsr TextUI
;jsr Reset
jsr GETIN
cmp #0 ;If no input wait for input
beq @Main_loop
cmp #$51 ;If Q then exit game
beq @Quit
stz Vsync_enabled ;Reset Vsync_enabled
bra @Main_loop ;Unexpected keystroke back to loop
@Quit:
sei ;Disable IRQ while restoring default_irq_vector
lda default_irq_vector
sta IRQVec
lda default_irq_vector+1
sta IRQVec+1
cli ;Reenable IRQ
rts
Custom_IRQ
lda VERA_ISR
and #$01
beq @continue ;Non Vsync continue to normal IRQ
lda #1
sta Vsync_enabled
@continue
jmp (default_irq_vector)