riven: foolishly working on better disk support

This commit is contained in:
Vince Weaver
2024-06-20 17:10:02 -04:00
parent 88f3f33658
commit 748942b164
11 changed files with 176 additions and 127 deletions

View File

@@ -279,4 +279,7 @@ qload.inc: generate_common QLOAD_01
./generate_common -a 0x1800 -s save_bg_14x14 qload_01.lst >> qload.inc
./generate_common -a 0x1800 -s handle_keypress qload_01.lst >> qload.inc
./generate_common -a 0x1800 -s change_location qload_01.lst >> qload.inc
./generate_common -a 0x1800 -s move_and_print qload_01.lst >> qload.inc
./generate_common -a 0x1800 -s set_normal qload_01.lst >> qload.inc

View File

@@ -1,3 +1,9 @@
+ disk handling code
+ on every load check to make sure disk hasn't been swapped?
can put expected disk number at beginning of each thing
we load and compare against it
+ common
+ move change-disk message to be in TITLE?
how to handle if multiple exits to level?

View File

@@ -1,6 +1,3 @@
which_disk_array:
.byte 1,1,1,1 ; TITLE, ARRIVAL
load_address_array:
.byte $40,$40,$40,$40 ; TITLE, ARRIVAL
@@ -12,3 +9,11 @@ sector_array:
length_array:
.byte 16, 128,123, 64 ; TITLE, ARRIVAL
disk_exit_disk: ; note: BCD (yes I'm lazy)
disk_exit_dni_h:
disk_exit_dni_l:
disk_exit_load:
disk_exit_level:
disk_exit_direction:

View File

@@ -1,7 +1,3 @@
which_disk_array:
.byte 1,1,1,1 ; TITLE, OUTSIDE, PROJECTOR, MAGSTEPS
.byte 1,1,1,1 ; MAGLEV, MOVIE1, MOVIE2
load_address_array:
.byte $40,$40,$40,$40 ; TITLE, OUTSIDE, PROJECTOR, MAGSTEPS
.byte $40,$40,$40 ; MAGLEV, MOVIE1, MOVIE2
@@ -17,3 +13,10 @@ sector_array:
length_array:
.byte 16, 123,123, 64 ; TITLE, OUTSIDE, PROJECTOR, MAGSTEPS
.byte 64, 32, 128 ; MAGLEV, MOVIE1, MOVIE2
disk_exit_disk: ; note: BCD (yes I'm lazy)
disk_exit_dni_h:
disk_exit_dni_l:
disk_exit_load:
disk_exit_level:
disk_exit_direction:

View File

@@ -1,6 +1,3 @@
which_disk_array:
.byte 1,1,1,1 ; TITLE, MAGLEV, OUTSIDE
load_address_array:
.byte $40,$40,$40,$40 ; TITLE, MAGLEV, OUTSIDE
@@ -12,3 +9,27 @@ sector_array:
length_array:
.byte 16, 96,96, 64 ; TITLE, MAGLEV, OUTSIDE
disk_exit_disk: ; note: BCD (yes I'm lazy)
.byte $43 ; CART (DISK43)
disk_exit_dni_h:
.byte $01
disk_exit_dni_l:
.byte $24
; load_cart / outside_cart / s
disk_exit_load:
.byte 1 ; LOAD_CART
disk_exit_level:
.byte $00 ; OUTSIDE_CART
disk_exit_direction:
.byte DIRECTION_S ; CART

View File

@@ -1,6 +1,3 @@
which_disk_array:
.byte 1,1,1,1 ; TITLE, CART
load_address_array:
.byte $40,$40,$40,$40 ; TITLE, CART
@@ -12,3 +9,11 @@ sector_array:
length_array:
.byte 16, 96,123, 64 ; TITLE, CART
disk_exit_disk: ; note: BCD (yes I'm lazy)
disk_exit_dni_h:
disk_exit_dni_l:
disk_exit_load:
disk_exit_level:
disk_exit_direction:

View File

@@ -46,6 +46,7 @@ CLRTOP = $F836 ;; clear only top of low-res screen
SETCOL = $F864 ;; COLOR=A
ROM_TEXT2COPY = $F962 ;; iigs
TEXT = $FB36
GR = $FB40
TABV = $FB5B ;; VTAB to A
ROM_MACHINEID = $FBB3 ;; iigs
BELL = $FBDD ;; ring the bell

View File

@@ -406,6 +406,17 @@ cant_go_forward:
rts
;=========================================
; need to load new "level"/area from disk
;=========================================
; level from disk = top 4 bits
; location = bottom 4 bits
; 12 possible levels per disk. 1..13
; $0 special, means same level
; $E special, means "new disk"
; bottom 4 bits = exit info
; $F special, means "can't go here" when clicked
new_level:
pha
lsr
@@ -413,7 +424,10 @@ new_level:
lsr
lsr
sta WHICH_LOAD
cmp #$E
beq new_disk
sta WHICH_LOAD ; which level to load from disk
pla
and #$0f
@@ -437,6 +451,13 @@ new_level:
rts
new_disk:
pla
and #$f
ora #$80
sta LEVEL_OVER
rts
;==========================
; turn left

View File

@@ -1,5 +1,10 @@
; Loader for Riven
; Based on QLOAD by qkumba which loads raw tracks off of disks
; This particular version only supports using a single disk drive
; (I have other versions that can look for disks across two drives)
.include "zp.inc"
.include "hardware.inc"
@@ -21,79 +26,44 @@
.include "disk43_files/disk43_defines.inc"
.endif
LOAD_FIRST_SECTOR = 22 ; ???
tmpsec = $3C
;WHICH_LOAD=$80
;WHICH_SLOT=$DA
;CURRENT_DISK=$DC
;OUTL = $FE
;OUTH = $FF
qload_start:
; 0..$10?
; 0 1 2 3 4 5 6 7 8 9 a b c d e f 10
; AA AA AA AA AA 07 05 40 20 01 01 01 00 0A 00 AA AA
; 00 C6 00 00 ff 07 05 40 20 00 01 01 00 0a 00 00 AA
; $300
; 80+OK, 40 bad, 60 bad, 70 good, 68=bad
; 0 1 2 3 4 5 6 7 8 9 A B C D
; $360 = DC E0 00 E4 E8 EC F0 F4 00 00 00 00 = bad
; $360 = dc e0 00 e4 e8 ec f0 f4 f8 fc 00 00 00 01 00 00 02 03 = good
; boot = ff ff 00 00 ff ff 00 00 ff ff 00 00 00 01 00 00 02 03
; preshift table is $300 - $369
; $36C to $3D5 is used as decode table by disk II drive
.if 0
ldy WHICH_SLOT ; temporarily save
lda #$AA
ldx #$2
zp_clear_loop:
sta $00,X
inx
bne zp_clear_loop
sty WHICH_SLOT
.endif
; init the write code
; init the write code if needed
lda WHICH_SLOT
; jsr popwr_init
; first time entry
; start by loading text title
; start by loading the title screen
; also set value indicating this is a warm boot, not disk change
lda #1
sta NEW_GAME
lda #LOAD_TITLE ; load title
sta WHICH_LOAD
lda #1
sta CURRENT_DISK ; current disk number
sta DRIVE1_DISK ; it's in drive1
sta CURRENT_DRIVE ; and currently using drive 1
sta CURRENT_DRIVE ; not needed for single drive code?
lda #$FF
sta DRIVE1_TRACK
sta DRIVE2_TRACK
sta DRIVE1_TRACK ; not needed for single drive code?
; need to modify qboot in that case
; jsr load_file ; actually load intro
; jsr $1000 ; run intro
; lda #LOAD_TITLE ; next load title
; sta WHICH_LOAD
main_game_loop:
jsr load_file
jsr $4000 ; all entry points currently $4000
; CHECK LEVEL_OVER
; if high bit set, jump to change_disk
lda LEVEL_OVER
bmi change_disk
jmp main_game_loop
@@ -103,11 +73,6 @@ main_game_loop:
load_file:
ldx WHICH_LOAD
lda which_disk_array,X ; get disk# for file to load
cmp CURRENT_DISK ; if not currently using
bne change_disk ; need to change disk
load_file_no_diskcheck:
lda load_address_array,X
sta load_address
@@ -129,65 +94,69 @@ load_file_no_diskcheck:
; change disk
;===================================================
;===================================================
; WHICH_LOAD is still in X?
; LEVEL_OVER bottom 4 bits hold which exit
change_disk:
; see if disk we want is in drive1
check_drive1:
lda which_disk_array,X
cmp DRIVE1_DISK
bne check_drive2
lda LEVEL_OVER
and #$f
sta LEVEL_OVER
tax
; jsr switch_drive1 ; switch to drive1
jmp update_disk
; set up locations
check_drive2:
cmp DRIVE2_DISK
bne disk_not_found
lda disk_exit_load,X
sta WHICH_LOAD
lda disk_exit_level,X
sta LOCATION
lda disk_exit_direction,X
sta DIRECTION
; jsr switch_drive2 ; switch to drive2
jmp update_disk
disk_not_found:
; check if disk in drive2
; carry clear if not
; jsr check_floppy_in_drive2
; bcc nothing_in_drive2
; a disk is in drive2, try to use it
; bcs verify_disk
nothing_in_drive2:
; switch back to drive1
; jsr switch_drive1
; see if disk we want is in drive
; TODO: load TITLE
; check disk number
; if no match, wait again
; if escape pressed, go back somehow?
;==============================
; print "insert disk" message
; TODO: switch to GR and print D'NI number too
jsr GR
jsr HOME
bit LORES
lda #<insert_disk_string
sta OUTL
lda #>insert_disk_string
sta OUTH
ldx WHICH_LOAD
lda which_disk_array,X
clc
adc #48
; patch error string to say correct disk to insert
ldy #27
ldy #21
lda disk_exit_disk,X
lsr
lsr
lsr
lsr
clc
adc #$30
sta (OUTL),Y
; jsr hgr_text_box
iny
lda disk_exit_disk,X
and #$f
clc
adc #$30
sta (OUTL),Y
jsr move_and_print
jsr move_and_print
fnf_keypress:
lda KEYPRESS
@@ -198,6 +167,7 @@ fnf_keypress:
; actually verify proper disk is there
; read T0:S0 and verify proper disk
verify_disk:
.if 0
lda WHICH_LOAD
pha
@@ -239,26 +209,24 @@ is_disk3:
disk_compare:
cmp which_disk_array,X
bne change_disk ; disk mismatch
.endif
;==============================================
; all good, retry original load
update_disk:
ldx WHICH_LOAD
lda which_disk_array,X
sta CURRENT_DISK
; ldx WHICH_LOAD
; lda disk_edit_disk,X
; sta CURRENT_DISK
ldx CURRENT_DRIVE
sta DRIVE1_DISK-1,X ; indexed from 1
; ldx CURRENT_DRIVE
; sta DRIVE1_DISK-1,X ; indexed from 1
jmp load_file
; offset for disk number is 27
insert_disk_string:
.byte 0,43,24, 0,240,74
.byte 10,41
.byte "PLEASE INSERT DISK 1",13
.byte " THEN PRESS RETURN",0
.byte 9,20,"PLEASE INSERT DISK 01.",0 ; 21+22 location of disk number
.byte 11,21,"THEN PRESS ANY KEY",0
; common includes used by everyone
@@ -269,6 +237,9 @@ insert_disk_string:
.include "graphics_sprites/pointer_sprites.inc"
.include "hgr_14x14_sprite.s"
.include "keyboard.s"
.include "text_print.s"
.include "gr_offsets.s"
.if DISK=01
.include "disk01_files/disk01_qload.inc"

View File

@@ -27,6 +27,18 @@
riven_title:
;============================
; check to see if new game
; if so print title screen
; otherwise we get here after flipping disks
; so skip all the init
; lda NEW_GAME
; bne new_game
; jmp disk_change
new_game:
;===========================
; print the title message that used to be
; in hello.bas
@@ -277,6 +289,9 @@ clear_loop:
dex
bpl clear_loop
; init hi-res graphics
lda #$20
sta HGR_PAGE
jsr hgr_make_tables
@@ -352,17 +367,15 @@ clear_loop:
; includes
;==========================
; .include "zx02_optim.s"
.include "hgr_tables.s"
.include "wait_a_bit.s"
; .include "wait.s"
.include "hardware_detect.s"
.include "text_print.s"
; .include "text_print.s"
.include "gr_offsets.s"
; .include "gr_offsets.s"
; .include "lc_detect.s"

View File

@@ -74,9 +74,8 @@ SOUND_STATUS = $86
SCENE_COUNT = $87
ANIMATE_FRAME = $88
LEVEL_OVER = $89
GAME_OVER = $FF
TOUCHED_ENEMY = $80
NEXT_LEVEL = $01
NEXT_DISK = $80
LOCATIONS_L = $8A
LOCATIONS_H = $8B
@@ -84,6 +83,8 @@ DISP_PAGE = $8C
DRAW_PAGE = $8D
WHICH_OVERLAY = $8E
NEW_GAME = $8F
; Riven zero page addresses
@@ -99,7 +100,6 @@ IN_SPECIAL = $98
CURSOR_VISIBLE = $99
IN_LEFT = $9A
IN_RIGHT = $9B
UPDATE_POINTER = $9C
APPLEII_MODEL = $9D
HGR_PAGE = $9E