mirror of
https://github.com/a2-4am/million-perfect-letters.git
synced 2025-06-04 19:44:34 +00:00
add global prefs file for sound
This commit is contained in:
parent
1f1156d32d
commit
d4ee6b3a62
@ -1,2 +1,3 @@
|
||||
MILLION.SYSTEM=Type(FF),AuxType(2000),Access(C3)
|
||||
PROGRESS=Type(06),AuxType(8E10),Access(C3)
|
||||
PREFS=Type(04),AuxType(0000),Access(C3)
|
||||
|
@ -70,6 +70,7 @@ GENSCROLLUP = $1100 ; 0x0900 bytes
|
||||
HGRLO = $1A00 ; 0x00C0 bytes
|
||||
HGRHI = $1B00 ; 0x00C0 bytes
|
||||
WORLDFILEBUFFER = $1C00 ; 0x0400 bytes
|
||||
PREFSFILEBUFFER = $1C00 ; 0x0400 bytes (note: same as WORLDFILEBUFFER)
|
||||
|
||||
PROGRESSFILEBUFFER = $8A00; 0x0400 bytes
|
||||
PACKEDPROGRESS = $8E10 ; 0x00C0 bytes
|
||||
|
170
src/glue.mli.a
170
src/glue.mli.a
@ -3,6 +3,17 @@
|
||||
;
|
||||
; ProDOS MLI wrapper (6502 compatible)
|
||||
;
|
||||
; Public functions:
|
||||
; - LoadFile1Shot
|
||||
; - SaveFile1Shot
|
||||
; - CreateFile
|
||||
; - OpenFile
|
||||
; - ReadFile
|
||||
; - WriteFile
|
||||
; - SetMarkTo0
|
||||
; - FlushFile
|
||||
; - CloseFile
|
||||
; - Quit
|
||||
|
||||
; ProDOS constants (these are memory addresses)
|
||||
PRODOSMLI = $BF00 ; [callable] MLI entry point
|
||||
@ -25,20 +36,153 @@ CMD_FLUSH = $01CD ; flush an open, written file to disk
|
||||
CMD_SETMARK = $02CE ; change position in an open file
|
||||
CMD_SETEOF = $02D0 ; set file size
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; LoadFile1Shot
|
||||
; load a file into memory all at once, using ProDOS MLI calls
|
||||
;
|
||||
; in: stack contains 8 bytes of parameters:
|
||||
; +1 [word] address of pathname
|
||||
; +3 [word] address of data buffer (to receive file contents)
|
||||
; +5 [word] maximum length of data to read
|
||||
; +7 [word] address of ProDOS file buffer
|
||||
; out: if C set, load failed and A contains error code from open or read
|
||||
; if C clear, load succeeded
|
||||
; all other flags & registers clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
LoadFile1Shot
|
||||
+PARAMS_ON_STACK 8
|
||||
+LDPARAM16 1, @filename
|
||||
+LDPARAM16 3, @databuffer
|
||||
+LDPARAM16 5, @datalength
|
||||
+LDPARAM16 7, @filebuffer
|
||||
|
||||
jsr OpenFile
|
||||
@filename
|
||||
!word $FDFD
|
||||
@filebuffer
|
||||
!word $FDFD
|
||||
bcs @exit
|
||||
|
||||
sta @refnum
|
||||
jsr ReadFile
|
||||
@refnum
|
||||
!byte $FD
|
||||
@databuffer
|
||||
!word $FDFD
|
||||
@datalength
|
||||
!word $FDFD
|
||||
|
||||
php
|
||||
lda @refnum
|
||||
jsr CloseFile
|
||||
plp
|
||||
@exit rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; SaveFile1Shot
|
||||
; save a file to disk all at once, using ProDOS MLI calls
|
||||
;
|
||||
; in: stack contains 11 ($0B) bytes of parameters:
|
||||
; +1 address of pathname
|
||||
; +3 [byte] file type (if we need to create the file)
|
||||
; +4 [word] aux file type
|
||||
; +6 [word] address of data buffer
|
||||
; +8 [word] length of data buffer
|
||||
; +A [word] address of ProDOS file buffer
|
||||
; out: if C set, save failed and A contains error code
|
||||
; from open or write
|
||||
; if C clear, save succeeded
|
||||
; all other flags & registers clobbered
|
||||
;------------------------------------------------------------------------------
|
||||
SaveFile1Shot
|
||||
+PARAMS_ON_STACK 11
|
||||
+LDPARAM16 $01, @filename
|
||||
+LDPARAM16 $01, @filename2
|
||||
+LDPARAM8 $03, @filetype
|
||||
+LDPARAM16 $04, @auxfiletype
|
||||
+LDPARAM16 $06, @databuffer
|
||||
+LDPARAM16 $08, @datalength
|
||||
+LDPARAM16 $0A, @filebuffer
|
||||
|
||||
- jsr OpenFile
|
||||
@filename
|
||||
!word $FDFD
|
||||
@filebuffer
|
||||
!word $FDFD
|
||||
bcc +
|
||||
|
||||
jsr CreateFile
|
||||
@filename2
|
||||
!word $FDFD
|
||||
@filetype
|
||||
!byte $FD
|
||||
@auxfiletype
|
||||
!word $FDFD
|
||||
bcs @exit
|
||||
bcc -
|
||||
|
||||
+ sta @refnum
|
||||
|
||||
jsr WriteFile
|
||||
@databuffer
|
||||
!word $FDFD
|
||||
@datalength
|
||||
!word $FDFD
|
||||
|
||||
php ; save C flag from WriteFile
|
||||
pha ; save error code or file refnum
|
||||
@refnum=*+1
|
||||
lda #$FD ; SMC
|
||||
jsr CloseFile
|
||||
pla ; A = error code or file refnum from WriteFile
|
||||
plp ; get C flag from Writefile
|
||||
@exit rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; CreateFile
|
||||
; create a file via ProDOS MLI
|
||||
;
|
||||
; always sets access bits to $C3 (full access)
|
||||
; always sets creation to 0 (current date/time)
|
||||
; always sets storage type to 1 (file)
|
||||
; in: stack contains 5 bytes of parameters:
|
||||
; +1 address of pathname
|
||||
; +3 [byte] file type
|
||||
; +4 [word] aux file type
|
||||
; out: if error, C set and A contains error code
|
||||
; if success, C clear
|
||||
;------------------------------------------------------------------------------
|
||||
CreateFile
|
||||
+PARAMS_ON_STACK 5
|
||||
+LDPARAM16 1, mliparam+1 ; address of filename
|
||||
+LDPARAM8 3, mliparam+4 ; filetype
|
||||
+LDPARAM16 4, mliparam+5 ; aux filetype
|
||||
lda #$C3 ; = full access
|
||||
sta mliparam+3 ; set access bits
|
||||
ldy #1 ; = file
|
||||
sty mliparam+7 ; storage type
|
||||
dey ; = 0 (current date/time)
|
||||
sty mliparam+8 ; creation date
|
||||
sty mliparam+9
|
||||
sty mliparam+10 ; creation time
|
||||
sty mliparam+11
|
||||
+LDADDR CMD_CREATE
|
||||
jmp mli
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; OpenFile
|
||||
; open file via ProDOS MLI
|
||||
;
|
||||
; in: stack contains 4 bytes of parameters:
|
||||
; +1 [word] address of filename
|
||||
; +3 [word] ProDOS file reference number
|
||||
; +3 [word] ProDOS file buffer
|
||||
; out: if C set, open failed and A contains error code
|
||||
; if C clear, open succeeded and A contains file reference number
|
||||
;------------------------------------------------------------------------------
|
||||
OpenFile
|
||||
+PARAMS_ON_STACK 4
|
||||
+LDPARAMPTR 1, mliparam+1 ; store filename
|
||||
+LDPARAMPTR 3, mliparam+3 ; store address of ProDOS file buffer
|
||||
+LDPARAM16 1, mliparam+1 ; address of filename
|
||||
+LDPARAM16 3, mliparam+3 ; address of ProDOS file buffer
|
||||
+LDADDR CMD_OPEN
|
||||
jsr mli
|
||||
bcs +
|
||||
@ -62,11 +206,9 @@ OpenFile
|
||||
;------------------------------------------------------------------------------
|
||||
ReadFile
|
||||
+PARAMS_ON_STACK 5
|
||||
ldy #1
|
||||
lda (PARAM), y
|
||||
sta mliparam+1 ; store file reference number
|
||||
+LDPARAMPTR 2, mliparam+2 ; store address of data buffer
|
||||
+LDPARAMPTR 4, mliparam+4 ; store data length
|
||||
+LDPARAM8 1, mliparam+1 ; file reference number
|
||||
+LDPARAM16 2, mliparam+2 ; address of data buffer
|
||||
+LDPARAM16 4, mliparam+4 ; data length
|
||||
+LDADDR CMD_READ
|
||||
jsr mli
|
||||
bcs +
|
||||
@ -86,10 +228,10 @@ ReadFile
|
||||
; number that was passed in
|
||||
;------------------------------------------------------------------------------
|
||||
WriteFile
|
||||
sta mliparam+1 ; store file reference number
|
||||
sta mliparam+1 ; file reference number
|
||||
+PARAMS_ON_STACK 4
|
||||
+LDPARAMPTR 1, mliparam+2 ; store data buffer address
|
||||
+LDPARAMPTR 3, mliparam+4 ; store data buffer length
|
||||
+LDPARAM16 1, mliparam+2 ; data buffer address
|
||||
+LDPARAM16 3, mliparam+4 ; data buffer length
|
||||
+LDADDR CMD_WRITE
|
||||
jsr mli
|
||||
bcs + ; error, A contains MLI error code
|
||||
@ -106,7 +248,7 @@ WriteFile
|
||||
; number that was passed in
|
||||
;------------------------------------------------------------------------------
|
||||
SetMarkTo0
|
||||
sta mliparam+1 ; store file reference number
|
||||
sta mliparam+1 ; file reference number
|
||||
lda #0
|
||||
sta mliparam+2
|
||||
sta mliparam+3
|
||||
@ -123,7 +265,7 @@ SetMarkTo0
|
||||
; if success, C clear
|
||||
;------------------------------------------------------------------------------
|
||||
FlushFile
|
||||
sta mliparam+1 ; store file reference number
|
||||
sta mliparam+1 ; file reference number
|
||||
+LDADDR CMD_FLUSH
|
||||
bne mli ; always branches
|
||||
|
||||
@ -136,7 +278,7 @@ FlushFile
|
||||
; if success, C clear
|
||||
;------------------------------------------------------------------------------
|
||||
CloseFile
|
||||
sta mliparam+1 ; store file reference number
|
||||
sta mliparam+1 ; file reference number
|
||||
+LDADDR CMD_CLOSE
|
||||
bne mli ; always branches
|
||||
|
||||
|
27
src/macros.a
27
src/macros.a
@ -51,23 +51,10 @@
|
||||
}
|
||||
|
||||
; for functions that take parameters on the stack
|
||||
; load a 16-bit value from the parameters on the stack into A (low) and Y (high)
|
||||
; (assumes PARAMS_ON_STACK was used first)
|
||||
!macro LDPARAM .offset {
|
||||
ldy #.offset
|
||||
lda (PARAM),y
|
||||
pha
|
||||
iny
|
||||
lda (PARAM),y
|
||||
tay
|
||||
pla
|
||||
}
|
||||
|
||||
; for functions that take parameters on the stack
|
||||
; load a 16-bit value from the parameters on the stack into A (low) and Y (high)
|
||||
; load a 16-bit value from the parameters on the stack
|
||||
; then store it as new source
|
||||
; (assumes PARAMS_ON_STACK was used first)
|
||||
!macro LDPARAMPTR .offset,.dest {
|
||||
!macro LDPARAM16 .offset,.dest {
|
||||
ldy #.offset
|
||||
lda (PARAM),y
|
||||
sta .dest
|
||||
@ -76,6 +63,16 @@
|
||||
sta .dest+1
|
||||
}
|
||||
|
||||
; for functions that take parameters on the stack
|
||||
; load an 8-bit value from the parameters on the stack
|
||||
; then store it as new source
|
||||
; (assumes PARAMS_ON_STACK was used first)
|
||||
!macro LDPARAM8 .offset,.dest {
|
||||
ldy #.offset
|
||||
lda (PARAM),y
|
||||
sta .dest
|
||||
}
|
||||
|
||||
; load the address of .ptr into A (low) and Y (high)
|
||||
!macro LDADDR .ptr {
|
||||
lda #<.ptr
|
||||
|
@ -19,6 +19,7 @@
|
||||
FirstMover
|
||||
!pseudopc $4000 {
|
||||
Start
|
||||
jsr LoadPrefs
|
||||
jsr InitSound
|
||||
jsr LoadProgressFromDisk
|
||||
jsr TitlePage
|
||||
@ -66,16 +67,17 @@ Start
|
||||
sec
|
||||
bcs @GoToMainMenu
|
||||
|
||||
!source "src/puzzle.a"
|
||||
!source "src/hw.vbl.a"
|
||||
!source "src/hw.storage.a"
|
||||
!source "src/glue.mli.a"
|
||||
!source "src/glue.sound.a"
|
||||
!source "src/ui.title.a"
|
||||
!source "src/ui.main.menu.a"
|
||||
!source "src/ui.about.a"
|
||||
!source "src/ui.play.a"
|
||||
!source "src/ui.common.a"
|
||||
!source "src/puzzle.a"
|
||||
!source "src/storage.a"
|
||||
!source "src/prefs.a"
|
||||
!source "src/glue.sound.a"
|
||||
!source "src/glue.mli.a"
|
||||
!source "src/hw.vbl.a"
|
||||
!source "src/ui.font.courier.double.prime.a"
|
||||
!source "src/ui.font.courier.double.prime.data.a"
|
||||
!source "src/ui.font.heavy.silk.a"
|
||||
|
73
src/prefs.a
Normal file
73
src/prefs.a
Normal file
@ -0,0 +1,73 @@
|
||||
;license:MIT
|
||||
;(c) 2020 by 4am
|
||||
;
|
||||
|
||||
PREFSFILE !byte prefs_e-prefs_b
|
||||
prefs_b
|
||||
!text "PREFS"
|
||||
prefs_e
|
||||
|
||||
PREFSVER !byte $31
|
||||
PREFSSOUND !byte $FD
|
||||
PREFSCHEAT !byte $FD
|
||||
!byte $0D
|
||||
!raw "|||",$0D
|
||||
!raw "||+---CHEAT (0/1)",$0D
|
||||
!raw "|+---SOUND (0/1)",$0D
|
||||
!raw "+---PREFS VERSION (DO NOT CHANGE)",$0D
|
||||
PREFSWRITELEN = *-PREFSVER
|
||||
PREFSREADLEN = $0003
|
||||
CURRENTVER = $31 ; ASCII '1'
|
||||
DEFAULTSOUND = $31 ; ASCII '1'
|
||||
DEFAULTCHEAT = $30 ; ASCII '0'
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; LoadPrefs
|
||||
; load settings from disk
|
||||
;------------------------------------------------------------------------------
|
||||
LoadPrefs
|
||||
jsr LoadFile1Shot
|
||||
!word PREFSFILE
|
||||
!word PREFSVER
|
||||
!word PREFSREADLEN
|
||||
!word PREFSFILEBUFFER
|
||||
bcc @deserialize
|
||||
- lda #CURRENTVER ; no prefs, use default values
|
||||
sta PREFSVER
|
||||
lda #DEFAULTSOUND
|
||||
sta PREFSSOUND
|
||||
lda #DEFAULTCHEAT
|
||||
sta PREFSCHEAT
|
||||
@deserialize
|
||||
lda PREFSVER
|
||||
cmp #CURRENTVER
|
||||
bne - ; bad prefs version, use defaults
|
||||
lda PREFSSOUND
|
||||
cmp #$30
|
||||
beq +
|
||||
cmp #$31
|
||||
bne - ; bad sound option, use defaults
|
||||
+ and #$01
|
||||
sta gSoundPref
|
||||
rts
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
; SavePrefs
|
||||
; save settings to disk
|
||||
;------------------------------------------------------------------------------
|
||||
SavePrefs
|
||||
lda #CURRENTVER
|
||||
sta PREFSVER
|
||||
lda gSoundPref
|
||||
ora #$30
|
||||
sta PREFSSOUND
|
||||
lda #DEFAULTCHEAT
|
||||
sta PREFSCHEAT
|
||||
jsr SaveFile1Shot
|
||||
!word PREFSFILE
|
||||
!byte $04 ; text file
|
||||
!word $0000 ; no aux filetype
|
||||
!word PREFSVER
|
||||
!word PREFSWRITELEN
|
||||
!word PREFSFILEBUFFER
|
||||
rts
|
@ -54,31 +54,18 @@ MaybeLoadWorldFromDisk
|
||||
clc
|
||||
rts
|
||||
+ sta @filename+1
|
||||
jsr OpenFile
|
||||
!word @filename
|
||||
!word WORLDFILEBUFFER
|
||||
bcs @exit
|
||||
sta @refnum
|
||||
jsr ReadFile
|
||||
@refnum !byte $FD ; SMC
|
||||
jsr LoadFile1Shot
|
||||
!word @filename ; address of filename
|
||||
!word WORLDDATA ; load address
|
||||
!word $2F00 ; maximum length to read
|
||||
php
|
||||
bcs @closeAndPopStatus
|
||||
plp
|
||||
!word $2F00 ; maximum length
|
||||
!word WORLDFILEBUFFER ; address of ProDOS file buffer
|
||||
bcs @exit
|
||||
jsr @PreParseWorldData
|
||||
cpx #100
|
||||
bne +
|
||||
clc
|
||||
+HIDE_NEXT_BYTE
|
||||
+ sec
|
||||
php
|
||||
lda @filename+1
|
||||
sta @fileLoaded
|
||||
@closeAndPopStatus
|
||||
lda @refnum
|
||||
jsr CloseFile
|
||||
plp
|
||||
@exit rts
|
||||
@fileLoaded
|
||||
!byte $FF ; no file
|
||||
@ -399,4 +386,4 @@ FindPackedProgressAddr
|
||||
sta $FE
|
||||
bcc +
|
||||
inc $FF
|
||||
rts
|
||||
+ rts
|
@ -48,6 +48,7 @@ MainMenu
|
||||
lda gSoundPref
|
||||
eor #$01
|
||||
sta gSoundPref
|
||||
jsr SavePrefs
|
||||
jsr ReinitSoundAfterPrefChange
|
||||
clc
|
||||
bcc MainMenu
|
||||
@ -255,7 +256,7 @@ asterisk
|
||||
!byte "*"
|
||||
version
|
||||
!byte 4
|
||||
!raw "V1.0"
|
||||
!raw "V0.1"
|
||||
menuline_play
|
||||
!byte 20
|
||||
!raw "RETURN.....PLAY GAME"
|
||||
|
Loading…
x
Reference in New Issue
Block a user