2024-09-01 23:13:06 -04:00
|
|
|
; .setcpu "65C02"
|
|
|
|
.include "./macro.inc"
|
|
|
|
|
2024-09-07 22:24:51 -04:00
|
|
|
.org $8000
|
|
|
|
|
2024-09-01 23:13:06 -04:00
|
|
|
n = $01 ; temporary storage for data stack operations
|
|
|
|
|
2024-09-07 22:24:51 -04:00
|
|
|
temp = $20 ; scratchpad page
|
2024-09-01 23:13:06 -04:00
|
|
|
|
2024-09-07 22:24:51 -04:00
|
|
|
cursor = $300
|
|
|
|
cursor_x = cursor
|
|
|
|
cursor_y = cursor + 1
|
2024-09-01 23:13:06 -04:00
|
|
|
|
2024-09-07 22:24:51 -04:00
|
|
|
rand_index = $200
|
2024-09-01 23:13:06 -04:00
|
|
|
|
|
|
|
reset:
|
|
|
|
sei
|
|
|
|
ldx #0; initialize data stack pointer
|
|
|
|
|
2024-09-07 22:24:51 -04:00
|
|
|
init:
|
|
|
|
cli
|
2024-09-01 23:13:06 -04:00
|
|
|
|
|
|
|
main:
|
2024-09-07 22:24:51 -04:00
|
|
|
jsr print
|
|
|
|
jsr rand_draw
|
2024-09-01 23:13:06 -04:00
|
|
|
jmp main
|
|
|
|
|
2024-09-07 22:24:51 -04:00
|
|
|
newline: ; sets cursor to start of next line
|
|
|
|
stz cursor_x
|
|
|
|
lda cursor_y
|
|
|
|
cmp #28
|
|
|
|
bne .end
|
|
|
|
stz cursor_y
|
|
|
|
rts
|
2024-09-01 23:13:06 -04:00
|
|
|
.end:
|
2024-09-07 22:24:51 -04:00
|
|
|
inc cursor_y
|
|
|
|
rts
|
|
|
|
|
|
|
|
text:
|
2024-09-26 21:02:03 -04:00
|
|
|
.byte 1,2,3,2,4
|
|
|
|
.asciiz "- george loves u <3"
|
2024-09-07 22:24:51 -04:00
|
|
|
|
|
|
|
random_y:
|
|
|
|
.byte 25,12,0,20,4,25,5,13
|
|
|
|
.byte 20, 1, 1, 22, 12, 19, 19, 19
|
|
|
|
.byte 9, 0, 4, 18, 13, 14, 4, 16
|
|
|
|
.byte 8, 17, 21, 14, 23, 21, 9, 0
|
|
|
|
.byte 14, 10, 14, 2, 26, 18, 15, 23
|
|
|
|
.byte 12, 2, 5, 4, 25, 20, 27, 4
|
|
|
|
.byte 28, 21, 3, 22, 11, 25, 2, 25
|
|
|
|
.byte 13, 17, 17, 24, 8, 8, 20, 21
|
|
|
|
.byte 11, 24, 27, 25, 8, 12, 7, 0
|
|
|
|
.byte 27, 12, 19, 27, 10, 3, 19, 2
|
|
|
|
.byte 2, 23, 22, 5, 26, 28, 4, 16
|
|
|
|
.byte 18, 7, 10, 9, 6, 19, 9, 2
|
|
|
|
.byte 14, 8, 14, 18, 18, 2, 13, 0
|
|
|
|
.byte 15, 26, 3, 23, 17, 12, 18, 11
|
|
|
|
.byte 4, 16, 17, 22, 9, 25, 3, 15
|
|
|
|
.byte 28, 3, 6, 14, 25, 5, 21, 8
|
|
|
|
.byte 15, 18, 15, 5, 28, 6, 15, 4
|
|
|
|
.byte 10, 1, 16, 24, 6, 9, 22, 3
|
|
|
|
.byte 17, 18, 10, 19, 27, 11, 22, 16
|
|
|
|
.byte 22, 17, 15, 6, 23, 11, 11, 11
|
|
|
|
.byte 4, 15, 5, 25, 19, 1, 8, 26
|
|
|
|
.byte 21, 20, 17, 27, 11, 3, 11, 20
|
|
|
|
.byte 15, 28, 0, 6, 14, 23, 20, 21
|
|
|
|
.byte 17, 20, 16, 15, 19, 6, 21, 19
|
|
|
|
.byte 15, 27, 1, 22, 7, 0, 5, 2
|
|
|
|
.byte 14, 24, 15, 4, 20, 16, 1, 14
|
|
|
|
.byte 4, 16, 4, 8, 13, 26, 3, 9
|
|
|
|
.byte 12, 25, 5, 0, 7, 17, 14, 20
|
|
|
|
.byte 2, 26, 2, 27, 18, 23, 5, 8
|
|
|
|
.byte 4, 21, 10, 11, 28, 22, 6, 6
|
|
|
|
.byte 10, 13, 23, 12, 20, 28, 20, 1
|
|
|
|
.byte 27, 19, 25, 6, 1, 10, 1
|
|
|
|
|
|
|
|
random_x:
|
|
|
|
.byte 42, 59, 11, 5, 18, 0, 26, 1
|
|
|
|
.byte 61, 16, 1, 51, 36, 47, 23, 1
|
|
|
|
.byte 16, 50, 46, 4, 55, 31, 15, 2
|
|
|
|
.byte 45, 21, 59, 53, 15, 43, 0, 2
|
|
|
|
.byte 64, 31, 38, 41, 25, 12, 12, 3
|
|
|
|
.byte 30, 13, 64, 44, 21, 8, 48, 3
|
|
|
|
.byte 46, 1, 2, 33, 4, 32, 59, 28
|
|
|
|
.byte 4, 24, 58, 53, 21, 41, 30, 2
|
|
|
|
.byte 56, 53, 31, 10, 42, 12, 9, 54
|
|
|
|
.byte 14, 14, 24, 29, 43, 60, 54, 26
|
|
|
|
.byte 5, 53, 17, 55, 27, 46, 31, 3
|
|
|
|
.byte 26, 44, 63, 30, 10, 34, 62, 48
|
|
|
|
.byte 42, 47, 51, 7, 55, 32, 14, 21
|
|
|
|
.byte 15, 26, 52, 37, 48, 0, 13, 2
|
|
|
|
.byte 50, 20, 35, 32, 8, 41, 2, 24
|
|
|
|
.byte 18, 9, 52, 22, 52, 12, 19, 32
|
|
|
|
.byte 29, 46, 34, 58, 54, 51, 43, 57
|
|
|
|
.byte 62, 10, 12, 57, 36, 39, 4, 30
|
|
|
|
.byte 38, 9, 30, 32, 33, 57, 3, 25
|
|
|
|
.byte 21, 36, 59, 30, 19, 39, 9, 60
|
|
|
|
.byte 34, 50, 52, 37, 34, 42, 3, 33
|
|
|
|
.byte 40, 19, 2, 26, 10, 38, 46, 30
|
|
|
|
.byte 3, 1, 19, 16, 26, 58, 42, 49
|
|
|
|
.byte 63, 1, 63, 41, 0, 21, 41, 19
|
|
|
|
.byte 21, 45, 44, 52, 20, 5, 11, 64
|
|
|
|
.byte 1, 62, 16, 5, 5, 8, 58, 56
|
|
|
|
.byte 16, 26, 6, 37, 19, 16, 25, 29
|
|
|
|
.byte 64, 59, 16, 6, 41, 28, 8, 51
|
|
|
|
.byte 54, 5, 19, 28, 13, 38, 52, 35
|
|
|
|
.byte 42, 13, 34, 33, 61, 61, 7, 27
|
|
|
|
.byte 38, 33, 9, 57, 10, 30, 8, 4
|
|
|
|
.byte 46, 3, 39, 46, 62, 20, 48, 7
|
|
|
|
|
|
|
|
|
|
|
|
; increments the cursor line by line, looping to (0, 0) after (63, 28)
|
|
|
|
|
|
|
|
inc_cursor:
|
|
|
|
lda cursor_x
|
|
|
|
cmp #63
|
|
|
|
beq .newline
|
|
|
|
inc cursor_x
|
2024-09-01 23:13:06 -04:00
|
|
|
rts
|
2024-09-07 22:24:51 -04:00
|
|
|
.newline:
|
|
|
|
lda cursor_y
|
|
|
|
cmp #28
|
|
|
|
beq .newscreen
|
|
|
|
stz cursor_x
|
|
|
|
inc cursor_y
|
|
|
|
rts
|
|
|
|
.newscreen:
|
|
|
|
stz cursor_y
|
|
|
|
stz cursor_x
|
|
|
|
rts
|
|
|
|
|
|
|
|
; zeroes out the display, resets cursor to 0,0
|
|
|
|
|
|
|
|
clear:
|
|
|
|
lda #0
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
.loop:
|
|
|
|
sta $6000,y
|
|
|
|
sta $6100,y
|
|
|
|
sta $6200,y
|
|
|
|
sta $6300,y
|
|
|
|
sta $6400,y
|
|
|
|
sta $6500,y
|
|
|
|
sta $6600,y
|
|
|
|
sta $6700,y ; this goes slightly over but it's fine
|
|
|
|
iny
|
|
|
|
bne .loop
|
|
|
|
stz cursor
|
|
|
|
stz cursor + 1
|
2024-09-01 23:13:06 -04:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
2024-09-07 22:24:51 -04:00
|
|
|
; prints string from cursor position, stopping at end of string or at 256 chars, whichever comes first
|
|
|
|
; $6000 + (64*Y) + X
|
|
|
|
; THIS WILL WRITE OUT OF BOUNDS IF THE CURSOR IS OUT OF BOUNDS/STRING IS TOO LONG
|
|
|
|
|
|
|
|
; TODO: figure out a simple way of writing arbitrary length strings
|
|
|
|
|
|
|
|
print:
|
|
|
|
jsr cursor_addr
|
|
|
|
ldy #0
|
|
|
|
; y_overflow = temp + 5
|
|
|
|
.loop:
|
|
|
|
lda text, y
|
|
|
|
beq .end
|
|
|
|
sta (temp), y
|
|
|
|
iny
|
|
|
|
bra .loop
|
|
|
|
.end:
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
; calculates real vram address from cursor (x, y)
|
|
|
|
|
|
|
|
cursor_addr:
|
|
|
|
stz temp
|
|
|
|
stz temp + 1
|
|
|
|
lda cursor_y
|
|
|
|
beq .add_x ; if y's zero just add x
|
|
|
|
.y_mult:
|
|
|
|
; multiply by 64
|
|
|
|
clc
|
|
|
|
asl
|
|
|
|
rol temp + 1
|
|
|
|
asl
|
|
|
|
rol temp + 1
|
|
|
|
asl
|
|
|
|
rol temp + 1
|
|
|
|
asl
|
|
|
|
rol temp + 1
|
|
|
|
asl
|
|
|
|
rol temp + 1
|
|
|
|
asl
|
|
|
|
rol temp + 1
|
|
|
|
sta temp
|
|
|
|
.add_x:
|
|
|
|
clc
|
|
|
|
lda cursor_x
|
|
|
|
adc temp
|
|
|
|
sta temp
|
|
|
|
lda #0
|
|
|
|
adc temp + 1
|
|
|
|
sta temp + 1
|
|
|
|
clc
|
|
|
|
|
|
|
|
lda #$60
|
|
|
|
adc temp + 1
|
|
|
|
sta temp + 1
|
2024-09-01 23:13:06 -04:00
|
|
|
rts
|
|
|
|
|
2024-09-07 22:24:51 -04:00
|
|
|
|
|
|
|
rand_draw:
|
|
|
|
ldx rand_index
|
|
|
|
lda random_x, x
|
|
|
|
sta cursor_x
|
|
|
|
lda random_y, x
|
|
|
|
sta cursor_y
|
|
|
|
jsr cursor_addr
|
|
|
|
inc rand_index
|
|
|
|
rts
|
|
|
|
|
2024-09-01 23:13:06 -04:00
|
|
|
|
|
|
|
isr: ; interrupt service routine
|
|
|
|
pha
|
|
|
|
phx
|
|
|
|
phy
|
2024-09-07 22:24:51 -04:00
|
|
|
; jsr irq
|
2024-09-01 23:13:06 -04:00
|
|
|
ply
|
|
|
|
plx
|
|
|
|
pla
|
|
|
|
rti
|
|
|
|
|
|
|
|
.include "math.inc"
|
|
|
|
|
|
|
|
.org $fffc
|
|
|
|
.word reset
|
|
|
|
.word isr
|