mist: octagon: grid book now works

This commit is contained in:
Vince Weaver 2020-07-18 01:06:38 -04:00
parent 027c0522bd
commit 377b4e1695
5 changed files with 206 additions and 52 deletions

View File

@ -5,19 +5,19 @@
: :
: :
------------- : ------------- ------------- : -------------
: : : : : : : : : : : : : : : : :~: :~:~: : : :~:~: : : : :
------------- : ------------- ------------- : -------------
: : : : : : : : : : : : : : : :~: : :~: :~: : : :~:~: :~: :
------------- : ------------- ------------- : -------------
: : : : : : : : : : : : : : : :~:~:~:~:~: : : :~: :~: : : :
------------- : ------------- ------------- : -------------
: : : : : : : : : : : : : : : :~:~: :~:~:~: : :~: : :~: : :
------------- : ------------- ------------- : -------------
: : : : : : : : : : : : : : : : : : : :~: : : :~:~: : :~:~:
------------- : ------------- ------------- : -------------
: : : : : : : : : : : : : : : : : :~:~:~: : : :~:~:~:~:~: :
------------- : ------------- ------------- : -------------
299 : 300 157 : 158
: :
: :
: :

View File

@ -80,3 +80,4 @@
.byte $00 ; TREE_LEVEL = $C6 .byte $00 ; TREE_LEVEL = $C6
.byte $00 ; HOLDING_ITEM = $C7 .byte $00 ; HOLDING_ITEM = $C7
.byte $00 ; BOILER_VALVE = $C8 .byte $00 ; BOILER_VALVE = $C8
.byte $00 ; TRUNK_STATE = $C9

View File

@ -54,16 +54,13 @@ read_fireplace:
lda #127 lda #127
sta GRID_PAGE sta GRID_PAGE
lda #'1' lda #$1
sta grid_left_h sta grid_left_h
sta grid_right_h sta grid_right_h
lda #'2' lda #$27
sta grid_left_t sta grid_left_to
sta grid_right_t lda #$28
lda #'7' sta grid_right_to
sta grid_left_o
lda #'8'
sta grid_right_o
rts rts
@ -121,7 +118,9 @@ all_done_book:
;===============================
; draw fireplace grid pattern
;===============================
; draw random patterns ; draw random patterns
; base them on memory starting at $2000? ; base them on memory starting at $2000?
@ -130,7 +129,13 @@ all_done_book:
draw_book_grid: draw_book_grid:
ldy #8 lda GRID_PAGE
cmp #157
beq draw_page_num
draw_book_grid_left:
ldy #8 ; Y is VTAB of current line
fp_book_outer_loop: fp_book_outer_loop:
lda gr_offsets,Y lda gr_offsets,Y
@ -138,65 +143,170 @@ fp_book_outer_loop:
lda gr_offsets+1,Y lda gr_offsets+1,Y
clc clc
adc DRAW_PAGE adc DRAW_PAGE
sta fp_book_smc+2 sta fp_book_smc+2 ; point to begin of line
lda $2000,Y lda GRID_PAGE
asl
asl
asl
sta fp_book_lookup_smc+1
fp_book_lookup_smc:
lda $F000,Y ; use random part of memory?
sta TEMPY sta TEMPY
ldx #5 ldx #5
fp_book_inner_loop: fp_book_inner_loop:
ror TEMPY ror TEMPY ; rotate value out through carry
bcc fp_space bcc fp_space
lda #' '|$80 lda #' '|$80 ; draw black space
jmp fp_book_smc jmp fp_book_smc
fp_space: fp_space:
lda #' '&$3f lda #' '&$3f ; draw white space
fp_book_smc: fp_book_smc:
sta $400,X sta $400,X ; store char
inx inx
inx inx ; skip to next
cpx #17 cpx #17
bne fp_book_inner_loop bne fp_book_inner_loop
iny iny ; skip to next line
iny iny
iny iny
iny iny
cpy #32 cpy #32
bne fp_book_outer_loop bne fp_book_outer_loop
; draw page number
; line 34? $4d0? draw_book_grid_right:
ldy #8 ; Y is VTAB of current line
fp_book_outer_loopr:
lda gr_offsets,Y
sta fp_book_smcr+1
lda gr_offsets+1,Y
clc
adc DRAW_PAGE
sta fp_book_smcr+2 ; point to begin of line
lda GRID_PAGE
asl
asl
asl
sta fp_book_lookup_smcr+1
fp_book_lookup_smcr:
lda $F100,Y ; use random part of memory?
sta TEMPY
ldx #25
fp_book_inner_loopr:
ror TEMPY ; rotate value out through carry
bcc fp_spacer
lda #' '|$80 ; draw black space
jmp fp_book_smcr
fp_spacer:
lda #' '&$3f ; draw white space
fp_book_smcr:
sta $400,X ; store char
inx
inx ; skip to next
cpx #37
bne fp_book_inner_loopr
iny ; skip to next line
iny
iny
iny
cpy #32
bne fp_book_outer_loopr
; draw page number
draw_page_num:
; line 32? $450?
lda #$50 lda #$50
sta OUTL sta OUTL
lda #$4 lda #$4
clc clc
adc DRAW_PAGE adc DRAW_PAGE
sta OUTH sta OUTH ; point OUTL:OUTH to hundreds place
print_left_page:
ldy #4 ldy #4
lda grid_left_h lda grid_left_h ; store hundreds, skipping if 0
beq glhz beq glhz
ora #$30
sta (OUTL),Y sta (OUTL),Y
iny iny
glhz: glhz:
lda grid_left_t lda grid_left_to ; store tens, skipping if 0
lsr
lsr
lsr
lsr
cpy #4 ; if still 4, need leading 0 check
bne glhzy
cmp #0
beq gltz beq gltz
glhzy:
ora #$30
sta (OUTL),Y sta (OUTL),Y
iny iny
gltz: gltz:
lda grid_left_o lda grid_left_to ; store ones
and #$f
ora #$30
sta (OUTL),Y sta (OUTL),Y
iny iny
lda #' ' lda #' '
sta (OUTL),Y ; write some blanks to erase any
iny ; trailing values
sta (OUTL),Y
print_right_page:
ldy #24
lda grid_right_h ; store hundreds, skipping if 0
beq glhzr
ora #$30
sta (OUTL),Y sta (OUTL),Y
iny iny
glhzr:
lda grid_right_to ; store tens, skipping if 0
lsr
lsr
lsr
lsr
cpy #24 ; if still 20, need leading 0 check
bne glhzyr
cmp #0
beq gltzr
glhzyr:
ora #$30
sta (OUTL),Y
iny
gltzr:
lda grid_right_to ; store ones
and #$f
ora #$30
sta (OUTL),Y
iny
lda #' '
sta (OUTL),Y ; write some blanks to erase any
iny ; trailing values
sta (OUTL),Y sta (OUTL),Y
rts rts
@ -213,19 +323,31 @@ turn_page:
decrement_page: decrement_page:
ldx GRID_PAGE ldx GRID_PAGE
cmp #1 cpx #1
beq done_decrement_page ; don't go lower than 1 beq done_decrement_page ; don't go lower than 1
dex dex
dex dex
stx GRID_PAGE stx GRID_PAGE
dec grid_left_o ; use decimal mode to decrement
dec grid_left_o sed
sec
dec grid_right_o lda grid_left_to
dec grid_right_o sbc #$2
sta grid_left_to
lda grid_left_h
sbc #$0
sta grid_left_h
sec
lda grid_right_to
sbc #$2
sta grid_right_to
lda grid_right_h
sbc #$0
sta grid_right_h
cld
done_decrement_page: done_decrement_page:
rts rts
@ -233,29 +355,40 @@ done_decrement_page:
increment_page: increment_page:
ldx GRID_PAGE ldx GRID_PAGE
cmp #253 ; don't go above 253/254 cpx #253 ; don't go above 253/254
beq done_increment_page beq done_increment_page
inx inx
inx inx
stx GRID_PAGE stx GRID_PAGE
inc grid_left_o ; use decimal mode to increment
inc grid_left_o sed
clc
lda grid_left_to
adc #$2
sta grid_left_to
lda grid_left_h
adc #$0
sta grid_left_h
inc grid_right_o clc
inc grid_right_o lda grid_right_to
adc #$2
sta grid_right_to
lda grid_right_h
adc #$0
sta grid_right_h
cld
done_increment_page: done_increment_page:
rts rts
grid_left_h: .byte '1' grid_left_h: .byte $1
grid_left_t: .byte '2' grid_left_to: .byte $27
grid_left_o: .byte '7' grid_right_h: .byte $1
grid_right_h: .byte '1' grid_right_to: .byte $28
grid_right_t: .byte '2'
grid_right_o: .byte '8'

View File

@ -38,6 +38,21 @@
; press right one, lights in the cabin go on ; press right one, lights in the cabin go on
; lighthouse backgrounds
; water, no trunk, hatch closed
; water, no trunk, hatch open
; water, trunk, hatch closed
; water, trunk, hatch open
; prev two, trunk open/closed
; nowater, hatch closed
; nowater, hatch open
; idea: baseline with water trunk, water no trunk, nowater
; draw hatch as sprite
;====================== ;======================
; handle umbrella pump buttons ; handle umbrella pump buttons

View File

@ -44,7 +44,7 @@ IN_RIGHT = $6B
BTC_L = $6C BTC_L = $6C
BTC_H = $6D BTC_H = $6D
; pt3 player registers
AY_REGISTERS = $70 AY_REGISTERS = $70
A_FINE_TONE = $70 A_FINE_TONE = $70
A_COARSE_TONE = $71 A_COARSE_TONE = $71
@ -66,7 +66,6 @@ PATTERN_H = $7F
; note: rest are up at $d0 ; note: rest are up at $d0
; We have to save/restore the following values ; We have to save/restore the following values
; when loading/storing from disk ; when loading/storing from disk
@ -233,7 +232,13 @@ HOLDING_ITEM = $C7
BOILER_VALVE = $C8 ; how many turns of the boiler valve BOILER_VALVE = $C8 ; how many turns of the boiler valve
END_OF_SAVE = $C9 TRUNK_STATE = $C9 ; trunk state in stonsehip
TRUNK_VALVE_OPEN = $01
TRUNK_WATER_DRAINED = $02
TRUNK_KEY_TAKEN = $04
TRUNK_HATCH_OPEN = $08
END_OF_SAVE = $CA
; done game puzzle state ; done game puzzle state