mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-23 08:36:06 +00:00
166 lines
2.8 KiB
Plaintext
166 lines
2.8 KiB
Plaintext
assign byte table screen $0400
|
|
assign byte table screen2 1274
|
|
assign byte table screen3 1524
|
|
assign byte table screen4 1774
|
|
|
|
assign byte table colormap 55296
|
|
assign byte table colormap2 55546
|
|
assign byte table colormap3 55796
|
|
assign byte table colormap4 56046
|
|
|
|
assign byte vic_border 53280
|
|
assign byte table vic_bg 53281
|
|
|
|
assign byte joy2 $dc00
|
|
|
|
assign vector cinv 788
|
|
|
|
; ---------
|
|
|
|
reserve vector save_cinv
|
|
|
|
assign word position $fb
|
|
assign word new_position $fd
|
|
|
|
reserve word delta
|
|
reserve byte value
|
|
reserve word compare_target
|
|
|
|
routine reset_position {
|
|
copy #$0400 position
|
|
}
|
|
|
|
routine advance_pos {
|
|
clc
|
|
lda <position
|
|
adc <delta
|
|
sta <new_position
|
|
lda >position
|
|
adc >delta
|
|
sta >new_position
|
|
}
|
|
|
|
routine install_new_position {
|
|
copy new_position position
|
|
}
|
|
|
|
routine compare_new_pos {
|
|
lda >new_position
|
|
cmp >compare_target
|
|
if beq {
|
|
lda <new_position
|
|
cmp <compare_target
|
|
} else {
|
|
}
|
|
}
|
|
|
|
routine check_new_position_in_bounds {
|
|
copy #$07e8 compare_target ; just past bottom of screen
|
|
jsr compare_new_pos
|
|
|
|
if bcs {
|
|
clc
|
|
} else {
|
|
|
|
copy #$0400 compare_target
|
|
jsr compare_new_pos
|
|
|
|
if bcc {
|
|
clc
|
|
} else {
|
|
sec
|
|
}
|
|
}
|
|
}
|
|
|
|
routine clear_screen {
|
|
ldy #0
|
|
repeat bne {
|
|
lda #1
|
|
sta colormap, y
|
|
sta colormap2, y
|
|
sta colormap3, y
|
|
sta colormap4, y
|
|
|
|
lda #32
|
|
sta screen, y
|
|
sta screen2, y
|
|
sta screen3, y
|
|
sta screen4, y
|
|
|
|
iny
|
|
cpy #250
|
|
}
|
|
}
|
|
|
|
routine read_stick {
|
|
lda #0
|
|
sta <delta
|
|
sta >delta
|
|
ldx joy2
|
|
txa
|
|
and #1 ; up
|
|
if beq {
|
|
lda #216 ; -40
|
|
sta <delta
|
|
lda #255
|
|
sta >delta
|
|
} else {
|
|
txa
|
|
and #2 ; down
|
|
if beq {
|
|
lda #40
|
|
sta <delta
|
|
} else {
|
|
txa
|
|
and #4 ; left
|
|
if beq {
|
|
lda #255 ; -1
|
|
sta <delta
|
|
lda #255
|
|
sta >delta
|
|
} else {
|
|
txa
|
|
and #8 ; right
|
|
if beq {
|
|
lda #1
|
|
sta <delta
|
|
} else { }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
routine our_cinv {
|
|
lda #32
|
|
ldy #0
|
|
sta (position), y
|
|
jsr read_stick
|
|
jsr advance_pos
|
|
jsr check_new_position_in_bounds
|
|
if bcs {
|
|
jsr install_new_position
|
|
} else { }
|
|
|
|
lda #81
|
|
ldy #0
|
|
sta (position), y
|
|
|
|
jmp (save_cinv)
|
|
}
|
|
|
|
routine main {
|
|
lda #5
|
|
sta vic_border
|
|
lda #0
|
|
sta vic_bg
|
|
jsr reset_position
|
|
jsr clear_screen
|
|
sei {
|
|
copy cinv save_cinv
|
|
copy routine our_cinv to cinv
|
|
}
|
|
clc
|
|
repeat bcc { }
|
|
}
|