Standardize indent

This commit is contained in:
stid 2020-01-12 17:24:10 -08:00
parent 222326bb1a
commit c8ba619d33
7 changed files with 538 additions and 516 deletions

View File

@ -22,15 +22,15 @@
// Module Init. // Module Init.
// -------------------------------------------------------- // --------------------------------------------------------
init: { init: {
// Init All Modules // Init All Modules
jsr Memory.init jsr Memory.init
jsr Math.init jsr Math.init
jsr Print.init jsr Print.init
jsr Keyboard.init jsr Keyboard.init
jsr Screen.init jsr Screen.init
jsr WozShell.init jsr WozShell.init
jsr Module.init jsr Module.init
rts rts
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -38,32 +38,31 @@ init: {
// Print debug info. // Print debug info.
// -------------------------------------------------------- // --------------------------------------------------------
toDebug: { toDebug: {
// Debug All Modules // Debug All Modules
ModuleToDebug(module_type, module_name, version) ModuleToDebug(module_type, module_name, version)
jsr Keyboard.toDebug jsr Keyboard.toDebug
jsr Screen.toDebug jsr Screen.toDebug
jsr Module.toDebug jsr Module.toDebug
jsr Memory.toDebug jsr Memory.toDebug
jsr Print.toDebug jsr Print.toDebug
jsr Math.toDebug jsr Math.toDebug
jsr WozShell.toDebug jsr WozShell.toDebug
rts rts
} }
// ======================================================== // ========================================================
// ////// DATA //////////////////////////////////////////// // ////// DATA ////////////////////////////////////////////
// ======================================================== // ========================================================
* = * "Init Core Data" * = * "Init Core Data"
module_type: .byte Module.TYPES.CORE module_type: .byte Module.TYPES.CORE
version: .byte 1, 1, 0 version: .byte 1, 1, 0
.encoding "screencode_mixed" .encoding "screencode_mixed"
module_name: module_name:
.text "init" .text "init"
.byte 0 .byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"

View File

@ -29,24 +29,24 @@
// Module Init. // Module Init.
// -------------------------------------------------------- // --------------------------------------------------------
init: { init: {
lda #64 lda #64
sta MemMap.KEYBOARD.SYS_Lstx sta MemMap.KEYBOARD.SYS_Lstx
sta MemMap.KEYBOARD.SYS_Sfdx sta MemMap.KEYBOARD.SYS_Sfdx
lda #cSYS_DelayValue lda #cSYS_DelayValue
sta MemMap.KEYBOARD.SYS_Delay sta MemMap.KEYBOARD.SYS_Delay
lda #6 lda #6
sta MemMap.KEYBOARD.SYS_Kount sta MemMap.KEYBOARD.SYS_Kount
lda #0 lda #0
sta MemMap.KEYBOARD.SYS_Shflag sta MemMap.KEYBOARD.SYS_Shflag
sta MemMap.KEYBOARD.SYS_Lstshf sta MemMap.KEYBOARD.SYS_Lstshf
sta MemMap.KEYBOARD.SYS_Ndx sta MemMap.KEYBOARD.SYS_Ndx
lda #10 lda #10
sta MemMap.KEYBOARD.SYS_Xmax sta MemMap.KEYBOARD.SYS_Xmax
// Clone self altering Methods to RAM // Clone self altering Methods to RAM
MemoryClone(cloneStart, cloneEnd, $1000) MemoryClone(cloneStart, cloneEnd, $1000)
@ -58,8 +58,8 @@ init: {
// Print debug info. // Print debug info.
// -------------------------------------------------------- // --------------------------------------------------------
toDebug: { toDebug: {
ModuleToDebug(module_type, module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
// ======================================================== // ========================================================
@ -67,7 +67,7 @@ toDebug: {
// ======================================================== // ========================================================
KeyMapVec: KeyMapVec:
.word KeyMap1, KeyMap2, KeyMap3, KeyMap4 .word KeyMap1, KeyMap2, KeyMap3, KeyMap4
// Unshifted // Unshifted
KeyMap1: KeyMap1:
@ -145,139 +145,151 @@ cloneStart:
// // Key here is in A // // Key here is in A
// -------------------------------------------------------- // --------------------------------------------------------
.pseudopc $1000 { .pseudopc $1000 {
ReadKeyb: ReadKeyb: {
lda #<KeyMap1 lda #<KeyMap1
sta @SMC_Vec sta @SMC_Vec
lda #>KeyMap1 lda #>KeyMap1
sta @SMC_Vec + 1 sta @SMC_Vec + 1
// Clear Shift Flag // Clear Shift Flag
lda #$40 lda #$40
sta MemMap.KEYBOARD.SYS_Sfdx sta MemMap.KEYBOARD.SYS_Sfdx
lda #0 lda #0
sta MemMap.KEYBOARD.SYS_Shflag sta MemMap.KEYBOARD.SYS_Shflag
sta CIA1_KeybWrite sta CIA1_KeybWrite
ldx CIA1_KeybRead ldx CIA1_KeybRead
cpx #$FF cpx #$FF
beq @Cleanup beq @Cleanup
ldy #$00 ldy #$00
lda #7 lda #7
sta MemMap.KEYBOARD.KeyR sta MemMap.KEYBOARD.KeyR
lda #cKeybW_Row1 lda #cKeybW_Row1
sta @SMC_Row + 1 sta @SMC_Row + 1
@SMC_Row: lda #0 @SMC_Row:
lda #0
sta CIA1_KeybWrite sta CIA1_KeybWrite
@Loop_Debounce: @Loop_Debounce:
lda CIA1_KeybRead lda CIA1_KeybRead
cmp CIA1_KeybRead cmp CIA1_KeybRead
bne @Loop_Debounce bne @Loop_Debounce
ldx #7 ldx #7
@Loop_Col: lsr @Loop_Col:
bcs @NextKey lsr
sta @SMC_A + 1 bcs @NextKey
sta @SMC_A + 1
lda @SMC_Vec:$FFFF,Y lda @SMC_Vec:$FFFF,Y
// If <4 then is Stop or a Shift Key // If <4 then is Stop or a Shift Key
cmp #$05 cmp #$05
bcs @NotShift // Not Shift bcs @NotShift // Not Shift
cmp #$03 cmp #$03
beq @NotShift // Stop Key beq @NotShift // Stop Key
// Accumulate shift key types (SHIFT=1, COMM=2, CTRL=4) // Accumulate shift key types (SHIFT=1, COMM=2, CTRL=4)
ora MemMap.KEYBOARD.SYS_Shflag ora MemMap.KEYBOARD.SYS_Shflag
sta MemMap.KEYBOARD.SYS_Shflag sta MemMap.KEYBOARD.SYS_Shflag
bpl @SMC_A bpl @SMC_A
@NotShift: sty MemMap.KEYBOARD.SYS_Sfdx @NotShift:
sty MemMap.KEYBOARD.SYS_Sfdx
@SMC_A: lda #0 @SMC_A:
lda #0
@NextKey: iny @NextKey:
iny
dex dex
bpl @Loop_Col bpl @Loop_Col
sec sec
rol @SMC_Row + 1 rol @SMC_Row + 1
dec MemMap.KEYBOARD.KeyR dec MemMap.KEYBOARD.KeyR
bpl @SMC_Row bpl @SMC_Row
jmp @ProcKeyImg jmp @ProcKeyImg
// Handles the key repeat // Handles the key repeat
@Process: ldy MemMap.KEYBOARD.SYS_Sfdx @Process:
@SMC_Key: lda $FFFF,Y ldy MemMap.KEYBOARD.SYS_Sfdx
@SMC_Key:
lda $FFFF,Y
tax tax
cpy MemMap.KEYBOARD.SYS_Lstx cpy MemMap.KEYBOARD.SYS_Lstx
beq @SameKey beq @SameKey
ldy #cSYS_DelayValue ldy #cSYS_DelayValue
sty MemMap.KEYBOARD.SYS_Delay // Repeat delay counter sty MemMap.KEYBOARD.SYS_Delay // Repeat delay counter
bne @Cleanup bne @Cleanup
@SameKey: and #$7F @SameKey:
ldy MemMap.KEYBOARD.SYS_Delay and #$7F
beq @EndDelay ldy MemMap.KEYBOARD.SYS_Delay
dec MemMap.KEYBOARD.SYS_Delay beq @EndDelay
bne @Exit dec MemMap.KEYBOARD.SYS_Delay
bne @Exit
@EndDelay: dec MemMap.KEYBOARD.SYS_Kount @EndDelay:
bne @Exit dec MemMap.KEYBOARD.SYS_Kount
bne @Exit
ldy #$04 ldy #$04
sty MemMap.KEYBOARD.SYS_Kount sty MemMap.KEYBOARD.SYS_Kount
ldy MemMap.KEYBOARD.SYS_Ndx ldy MemMap.KEYBOARD.SYS_Ndx
dey dey
bpl @Exit bpl @Exit
// Updates the previous key and shift storage // Updates the previous key and shift storage
@Cleanup: ldy MemMap.KEYBOARD.SYS_Sfdx @Cleanup:
sty MemMap.KEYBOARD.SYS_Lstx ldy MemMap.KEYBOARD.SYS_Sfdx
ldy MemMap.KEYBOARD.SYS_Shflag sty MemMap.KEYBOARD.SYS_Lstx
sty MemMap.KEYBOARD.SYS_Lstshf ldy MemMap.KEYBOARD.SYS_Shflag
sty MemMap.KEYBOARD.SYS_Lstshf
cpx #$FF cpx #$FF
beq @Exit beq @Exit
txa txa
ldx MemMap.KEYBOARD.SYS_Ndx ldx MemMap.KEYBOARD.SYS_Ndx
cpx MemMap.KEYBOARD.SYS_Xmax cpx MemMap.KEYBOARD.SYS_Xmax
bcs @Exit bcs @Exit
sta MemMap.KEYBOARD.SYS_Keyd,X sta MemMap.KEYBOARD.SYS_Keyd,X
inx inx
stx MemMap.KEYBOARD.SYS_Ndx stx MemMap.KEYBOARD.SYS_Ndx
@Exit: lda #$7F @Exit:
sta CIA1_KeybWrite lda #$7F
sta CIA1_KeybWrite
rts rts
@ProcKeyImg: @ProcKeyImg:
lda MemMap.KEYBOARD.SYS_Shflag lda MemMap.KEYBOARD.SYS_Shflag
cmp #$03 // C= + SHIFT cmp #$03 // C= + SHIFT
bne @SetDecodeTable bne @SetDecodeTable
cmp MemMap.KEYBOARD.SYS_Lstshf cmp MemMap.KEYBOARD.SYS_Lstshf
beq @Exit beq @Exit
@SetDecodeTable: @SetDecodeTable:
asl asl
cmp #8 // CONTROL cmp #8 // CONTROL
bcc @Cont bcc @Cont
lda #$06 lda #$06
@Cont: tax @Cont: tax
lda KeyMapVec,X lda KeyMapVec,X
sta @SMC_Key + 1 sta @SMC_Key + 1
lda KeyMapVec + 1,X lda KeyMapVec + 1,X
sta @SMC_Key + 2 sta @SMC_Key + 2
jmp @Process jmp @Process
}
// -------------------------------------------------------- // --------------------------------------------------------
// GetKey - // GetKey -
@ -287,25 +299,31 @@ ReadKeyb:
// Result: // Result:
// A = Pressed key code or 0 // A = Pressed key code or 0
// -------------------------------------------------------- // --------------------------------------------------------
GetKey: lda MemMap.KEYBOARD.SYS_Ndx GetKey: {
bne @IsKey
@NoKey: lda #255 // Null lda MemMap.KEYBOARD.SYS_Ndx
bne @IsKey
@NoKey:
lda #255 // Null
sec sec
rts rts
@IsKey: ldy MemMap.KEYBOARD.SYS_Keyd @IsKey:
ldx #0 ldy MemMap.KEYBOARD.SYS_Keyd
@Loop: lda MemMap.KEYBOARD.SYS_Keyd + 1,X ldx #0
sta MemMap.KEYBOARD.SYS_Keyd,X @Loop:
lda MemMap.KEYBOARD.SYS_Keyd + 1,X
sta MemMap.KEYBOARD.SYS_Keyd,X
inx inx
cpx MemMap.KEYBOARD.SYS_Ndx cpx MemMap.KEYBOARD.SYS_Ndx
bne @Loop bne @Loop
dec MemMap.KEYBOARD.SYS_Ndx dec MemMap.KEYBOARD.SYS_Ndx
tya tya
clc clc
rts rts
}
}}
* = * "Keyboard Ram End" * = * "Keyboard Ram End"
@ -316,13 +334,13 @@ cloneEnd:
// ======================================================== // ========================================================
* = * "Keyboard Module Data" * = * "Keyboard Module Data"
module_type: .byte Module.TYPES.CORE module_type: .byte Module.TYPES.CORE
version: .byte 1, 1, 0 version: .byte 1, 1, 0
.encoding "screencode_mixed" .encoding "screencode_mixed"
module_name: module_name:
.text "keyboard" .text "keyboard"
.byte 0 .byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"

View File

@ -26,8 +26,8 @@ init: {
// Print debug info. // Print debug info.
// -------------------------------------------------------- // --------------------------------------------------------
toDebug: { toDebug: {
ModuleToDebug(module_type, module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -47,20 +47,20 @@ multiply: {
txa txa
pha pha
lda #$00 lda #$00
ldx #$08 ldx #$08
clc clc
m0: bcc.r m1 m0: bcc.r m1
clc clc
adc MemMap.MATH.factor2 adc MemMap.MATH.factor2
m1: ror m1: ror
ror MemMap.MATH.factor1 ror MemMap.MATH.factor1
dex dex
bpl.r m0 bpl.r m0
ldx MemMap.MATH.factor1 ldx MemMap.MATH.factor1
sta MemMap.MATH.result sta MemMap.MATH.result
stx MemMap.MATH.result+1 stx MemMap.MATH.result+1
pla pla
tax tax
@ -75,13 +75,13 @@ multiply: {
// ======================================================== // ========================================================
* = * "Math Lib Data" * = * "Math Lib Data"
module_type: .byte Module.TYPES.LIB module_type: .byte Module.TYPES.LIB
version: .byte 1, 1, 0 version: .byte 1, 1, 0
.encoding "screencode_mixed" .encoding "screencode_mixed"
module_name: module_name:
.text "math" .text "math"
.byte 0 .byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"

View File

@ -18,22 +18,22 @@
// dest = Destination Memory pointer // dest = Destination Memory pointer
// -------------------------------------------------------- // --------------------------------------------------------
.macro MemoryClone(from, to, dest) { .macro MemoryClone(from, to, dest) {
lda #<from lda #<from
sta MemMap.MEMORY.from sta MemMap.MEMORY.from
lda #>from lda #>from
sta MemMap.MEMORY.from+1 sta MemMap.MEMORY.from+1
lda #<dest lda #<dest
sta MemMap.MEMORY.dest sta MemMap.MEMORY.dest
lda #>dest lda #>dest
sta MemMap.MEMORY.dest+1 sta MemMap.MEMORY.dest+1
lda #<to-from lda #<to-from
sta MemMap.MEMORY.size+1 sta MemMap.MEMORY.size+1
lda #>to-from lda #>to-from
sta MemMap.MEMORY.size sta MemMap.MEMORY.size
jsr Memory.clone jsr Memory.clone
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -46,18 +46,18 @@
// fillByte = Byte used to fill the range // fillByte = Byte used to fill the range
// -------------------------------------------------------- // --------------------------------------------------------
.macro MemoryFill(from, to, fillByte) { .macro MemoryFill(from, to, fillByte) {
lda #<from lda #<from
sta MemMap.MEMORY.from sta MemMap.MEMORY.from
lda #>from lda #>from
sta MemMap.MEMORY.from+1 sta MemMap.MEMORY.from+1
lda #<to-from lda #<to-from
sta MemMap.MEMORY.size+1 sta MemMap.MEMORY.size+1
lda #>to-from lda #>to-from
sta MemMap.MEMORY.size sta MemMap.MEMORY.size
lda #fillByte lda #fillByte
jsr Memory.fill jsr Memory.fill
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -69,17 +69,17 @@
// to = End Memory Pointer to fill // to = End Memory Pointer to fill
// -------------------------------------------------------- // --------------------------------------------------------
.macro MemoryClear(from, to) { .macro MemoryClear(from, to) {
lda #<from lda #<from
sta MemMap.MEMORY.from sta MemMap.MEMORY.from
lda #>from lda #>from
sta MemMap.MEMORY.from+1 sta MemMap.MEMORY.from+1
lda #<to-from lda #<to-from
sta MemMap.MEMORY.size+1 sta MemMap.MEMORY.size+1
lda #>to-from lda #>to-from
sta MemMap.MEMORY.size sta MemMap.MEMORY.size
jsr Memory.clear jsr Memory.clear
} }
@ -97,7 +97,7 @@
// Module Init. // Module Init.
// -------------------------------------------------------- // --------------------------------------------------------
init: { init: {
rts rts
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -105,8 +105,8 @@ init: {
// Print debug info. // Print debug info.
// -------------------------------------------------------- // --------------------------------------------------------
toDebug: { toDebug: {
ModuleToDebug(module_type, module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
@ -123,32 +123,32 @@ toDebug: {
// copy // copy
// -------------------------------------------------------- // --------------------------------------------------------
clone: { clone: {
stx MemMap.MEMORY.tmpX stx MemMap.MEMORY.tmpX
sty MemMap.MEMORY.tmpY sty MemMap.MEMORY.tmpY
sei sei
ldy #0 ldy #0
ldx MemMap.MEMORY.size ldx MemMap.MEMORY.size
beq md2 beq md2
md1: lda (MemMap.MEMORY.from),y // move a page at a time md1: lda (MemMap.MEMORY.from),y // move a page at a time
sta (MemMap.MEMORY.dest),y sta (MemMap.MEMORY.dest),y
iny iny
bne md1 bne md1
inc MemMap.MEMORY.from+1 inc MemMap.MEMORY.from+1
inc MemMap.MEMORY.dest+1 inc MemMap.MEMORY.dest+1
dex dex
bne md1 bne md1
md2: ldx MemMap.MEMORY.size+1 md2: ldx MemMap.MEMORY.size+1
beq md4 beq md4
md3: lda (MemMap.MEMORY.from),y // move the remaining bytes md3: lda (MemMap.MEMORY.from),y // move the remaining bytes
sta (MemMap.MEMORY.dest),y sta (MemMap.MEMORY.dest),y
iny iny
dex dex
bne md3 bne md3
cli cli
md4: md4:
ldx MemMap.MEMORY.tmpX ldx MemMap.MEMORY.tmpX
ldy MemMap.MEMORY.tmpY ldy MemMap.MEMORY.tmpY
rts rts
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -163,31 +163,31 @@ clone: {
// A = The byte to fill memory with // A = The byte to fill memory with
// -------------------------------------------------------- // --------------------------------------------------------
fill: { fill: {
stx MemMap.MEMORY.tmpX stx MemMap.MEMORY.tmpX
sty MemMap.MEMORY.tmpY sty MemMap.MEMORY.tmpY
sei sei
ldy #0 ldy #0
ldx MemMap.MEMORY.size ldx MemMap.MEMORY.size
beq md2 beq md2
md1: md1:
sta (MemMap.MEMORY.dest),y sta (MemMap.MEMORY.dest),y
iny iny
bne md1 bne md1
inc MemMap.MEMORY.dest+1 inc MemMap.MEMORY.dest+1
dex dex
bne md1 bne md1
md2: ldx MemMap.MEMORY.size+1 md2: ldx MemMap.MEMORY.size+1
beq md4 beq md4
md3: md3:
sta (MemMap.MEMORY.dest),y sta (MemMap.MEMORY.dest),y
iny iny
dex dex
bne md3 bne md3
cli cli
md4: md4:
ldx MemMap.MEMORY.tmpX ldx MemMap.MEMORY.tmpX
ldy MemMap.MEMORY.tmpY ldy MemMap.MEMORY.tmpY
rts rts
} }
// Clear Memory with 0 // Clear Memory with 0
@ -206,8 +206,8 @@ fill: {
// clean // clean
// -------------------------------------------------------- // --------------------------------------------------------
clean: { clean: {
lda #00 lda #00
jmp Memory.fill jmp Memory.fill
} }

View File

@ -10,17 +10,17 @@
// ======================================================== // ========================================================
.macro PrintLine(stringAddr) { .macro PrintLine(stringAddr) {
lda #<stringAddr // Low byte lda #<stringAddr // Low byte
ldx #>stringAddr // High byte ldx #>stringAddr // High byte
jsr Print.printLine jsr Print.printLine
} }
.macro PrintChar() { .macro PrintChar() {
jsr Print.printPetChar jsr Print.printPetChar
} }
.macro PrintNewLine() { .macro PrintNewLine() {
jsr Screen.screenNewLine jsr Screen.screenNewLine
} }
@ -78,17 +78,17 @@ printPetChar: {
// X = low byte string address // X = low byte string address
// -------------------------------------------------------- // --------------------------------------------------------
printLine: { printLine: {
ldy #$00 ldy #$00
sta MemMap.SCREEN.TempStringPointer sta MemMap.SCREEN.TempStringPointer
stx MemMap.SCREEN.TempStringPointer+1 stx MemMap.SCREEN.TempStringPointer+1
printLoop: printLoop:
lda (MemMap.SCREEN.TempStringPointer), y lda (MemMap.SCREEN.TempStringPointer), y
cmp #0 cmp #0
beq exit beq exit
jsr Screen.sendChar jsr Screen.sendChar
jmp printLoop jmp printLoop
exit: exit:
rts rts
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -103,27 +103,29 @@ printLine: {
// X = lns ascii char result // X = lns ascii char result
// -------------------------------------------------------- // --------------------------------------------------------
byteToHex: { byteToHex: {
pha //save byte pha //save byte
and #%00001111 //extract lsn and #%00001111 //extract lsn
tax //save it tax //save it
pla //recover byte pla //recover byte
lsr //extract... lsr //extract...
lsr //msn lsr //msn
lsr lsr
lsr lsr
pha //save msn pha //save msn
txa //lsn txa //lsn
jsr binhex1 //generate ascii lsn jsr binhex1 //generate ascii lsn
tax //save tax //save
pla //get msn & fall thru pla //get msn & fall thru
// //
// convert nybble to hex ascii equivalent... // convert nybble to hex ascii equivalent...
binhex1: cmp #$0a binhex1:
bcc binhex2 //in decimal range cmp #$0a
sbc #$09 //hex compensate bcc binhex2 //in decimal range
rts sbc #$09 //hex compensate
binhex2: eor #%00110000 //finalize nybble rts
rts //done binhex2:
eor #%00110000 //finalize nybble
rts //done
} }
// -------------------------------------------------------- // --------------------------------------------------------
@ -197,13 +199,13 @@ petCharToScreenChar: {
// ======================================================== // ========================================================
* = * "Print Lib Data" * = * "Print Lib Data"
module_type: .byte Module.TYPES.LIB module_type: .byte Module.TYPES.LIB
version: .byte 1, 0, 0 version: .byte 1, 0, 0
.encoding "screencode_mixed" .encoding "screencode_mixed"
module_name: module_name:
.text "print" .text "print"
.byte 0 .byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"

View File

@ -20,7 +20,7 @@
.const RASTER_LINE = $d012 .const RASTER_LINE = $d012
.const INTERRUPT_CTRL = $dc0d .const INTERRUPT_CTRL = $dc0d
.const NMSK_INTERRUPT_CTRL = $dd0d .const NMSK_INTERRUPT_CTRL = $dd0d
.const TIMER_A_CTRL = $DC0E .const TIMER_A_CTRL = $DC0E
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
.word coldstart // coldstart vector .word coldstart // coldstart vector
@ -39,78 +39,80 @@
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
* = * "Kernel Start" * = * "Kernel Start"
coldstart: coldstart: {
ldx #$FF ldx #$FF
sei sei
txs txs
cld cld
stx SCRN_CTRL // Set Screen Bits stx SCRN_CTRL // Set Screen Bits
jsr INIT_IRQ // Prepare IRQ jsr INIT_IRQ // Prepare IRQ
jsr INIT_MEM // Init memory. Rewrite this routine to speed up boot process. jsr INIT_MEM // Init memory. Rewrite this routine to speed up boot process.
jsr INIT_IO // Init I/O jsr INIT_IO // Init I/O
jsr INIT_VID // Init video jsr INIT_VID // Init video
cli cli
}
* = * "App Start" * = * "App Start"
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
start: start: {
jsr initApp; jsr initApp;
jsr WozShell.start jsr WozShell.start
loop:
lda #$FF
Raster:
cmp RASTER_LINE // Raster done?
bne Raster
jsr Keyboard.ReadKeyb
jsr Keyboard.GetKey
bcs loop
loop: cmp #CR
lda #$FF beq execute
Raster: cmp RASTER_LINE // Raster done?
bne Raster
jsr Keyboard.ReadKeyb
jsr Keyboard.GetKey
bcs loop
cmp #CR cmp #BS
beq execute beq backspace
inputChar:
cmp #BS jsr WozShell.push // Char in Buffer
beq backspace
inputChar:
jsr WozShell.push // Char in Buffer
PrintChar() PrintChar()
jmp loop jmp loop
backspace: backspace:
jsr WozShell.backspace jsr WozShell.backspace
PrintChar() PrintChar()
jmp loop jmp loop
execute: execute:
jsr WozShell.push // CR in Buffer jsr WozShell.push // CR in Buffer
jsr Screen.screenNewLine jsr Screen.screenNewLine
jsr WozShell.exec jsr WozShell.exec
jsr Screen.screenNewLine jsr Screen.screenNewLine
jsr WozShell.clear jsr WozShell.clear
jmp loop jmp loop
}
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
initApp: { initApp: {
sei sei
lda #$7f lda #$7f
sta INTERRUPT_CTRL // disable timer interrupts which can be generated by the two CIA chips sta INTERRUPT_CTRL // disable timer interrupts which can be generated by the two CIA chips
sta NMSK_INTERRUPT_CTRL // the kernal uses such an interrupt to flash the cursor and scan the keyboard, so we better sta NMSK_INTERRUPT_CTRL // the kernal uses such an interrupt to flash the cursor and scan the keyboard, so we better
// stop it. // stop it.
lda INTERRUPT_CTRL // by reading this two registers we negate any pending CIA irqs. lda INTERRUPT_CTRL // by reading this two registers we negate any pending CIA irqs.
lda NMSK_INTERRUPT_CTRL // if we don't do this, a pending CIA irq might occur after we finish setting up our irq. lda NMSK_INTERRUPT_CTRL // if we don't do this, a pending CIA irq might occur after we finish setting up our irq.
// we don't want that to happen. // we don't want that to happen.
// Disable 0e TIMER // Disable 0e TIMER
lda #254 lda #254
and TIMER_A_CTRL and TIMER_A_CTRL
sta TIMER_A_CTRL sta TIMER_A_CTRL
ScreenClearColorRam($00) ScreenClearColorRam($00)
ScreenClear(' ') ScreenClear(' ')
ScreenSetBorderColor(BORDER_COLOR) ScreenSetBorderColor(BORDER_COLOR)
ScreenSetBackgroundColor(MAIN_COLOR) ScreenSetBackgroundColor(MAIN_COLOR)
jsr Init.init jsr Init.init
cli cli
rts rts
} }
@ -118,8 +120,6 @@ initApp: {
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
* = * "Kernel Data" * = * "Kernel Data"
* = $9FFF "EpromFiller" * = $9FFF "EpromFiller"
.byte 0 .byte 0

View File

@ -11,8 +11,8 @@
// ////// CONSTANTS /////////////////////////////////////// // ////// CONSTANTS ///////////////////////////////////////
// ======================================================== // ========================================================
.const CR = $0d .const CR = $0d
.const R = $52 .const R = $52
// ======================================================== // ========================================================
@ -22,223 +22,226 @@
clear: clear:
init: { init: {
lda #-1
lda #-1 sta MemMap.SHELL.pos
sta MemMap.SHELL.pos rts
rts
} }
start: { start: {
PrintLine(lineString) PrintLine(lineString)
PrintLine(aboutString) PrintLine(aboutString)
PrintLine(lineString) PrintLine(lineString)
rts rts
} }
toDebug: { toDebug: {
ModuleToDebug(module_type, module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
push: { push: {
ldy MemMap.SHELL.pos ldy MemMap.SHELL.pos
iny iny
cpy #127 cpy #127
beq.r done beq.r done
sty MemMap.SHELL.pos sty MemMap.SHELL.pos
sta MemMap.SHELL.buffer, y sta MemMap.SHELL.buffer, y
done: done:
rts rts
} }
backspace: { backspace: {
ldy MemMap.SHELL.pos ldy MemMap.SHELL.pos
cpy #-1 cpy #-1
beq done beq done
dey dey
sty MemMap.SHELL.pos sty MemMap.SHELL.pos
done: done:
rts rts
} }
exec: { exec: {
lda MemMap.SHELL.buffer // Check first char lda MemMap.SHELL.buffer // Check first char
cmp #'!' cmp #'!'
beq stidExec // if ! is stid mon command beq stidExec // if ! is stid mon command
jmp wozExec // Otherwise exec Woz jmp wozExec // Otherwise exec Woz
// Expect exec functions to RTS // Expect exec functions to RTS
} }
stidExec: { stidExec: {
ldy #1 ldy #1
lda MemMap.SHELL.buffer, y lda MemMap.SHELL.buffer, y
cmp #$48 // H cmp #$48 // H
beq cmdHelp beq cmdHelp
cmp #$52 // R cmp #$52 // R
beq cmdReset beq cmdReset
cmp #$56 // Z cmp #$56 // Z
beq cmdZeroPageInfo beq cmdZeroPageInfo
done:
rts
// STID Commands
cmdHelp:
PrintLine(helpString)
jmp done
cmdReset:
jmp $fce2 // SYS 64738
done: cmdZeroPageInfo:
rts jsr Init.toDebug
jmp done
// STID Commands
cmdHelp:
PrintLine(helpString)
jmp done
cmdReset:
jmp $fce2 // SYS 64738
cmdZeroPageInfo:
jsr Init.toDebug
jmp done
} }
// WOZ MONITOR FLOW - FROM APPLE1 // WOZ MONITOR FLOW - FROM APPLE1
wozExec: { wozExec: {
ldy #-1 ldy #-1
lda #0 lda #0
tax tax
SETSTOR: SETSTOR:
asl asl
SETMODE: SETMODE:
cmp #0 cmp #0
beq.r !+ beq.r !+
eor #%10000000 eor #%10000000
!: !:
sta MemMap.SHELL.MODE sta MemMap.SHELL.MODE
BLSKIP: iny BLSKIP: iny
NEXTITEM: NEXTITEM:
lda MemMap.SHELL.buffer,Y //Get character lda MemMap.SHELL.buffer,Y //Get character
cmp #CR cmp #CR
bne.r CONT // We're done if it's CR! bne.r CONT // We're done if it's CR!
rts rts
CONT: CONT:
cmp #'.' cmp #'.'
bcc BLSKIP // Ignore everything below "."! bcc BLSKIP // Ignore everything below "."!
beq SETMODE // Set BLOCK XAM mode ("." = $AE) beq SETMODE // Set BLOCK XAM mode ("." = $AE)
cmp #':' cmp #':'
beq SETSTOR // Set STOR mode! $BA will become $7B beq SETSTOR // Set STOR mode! $BA will become $7B
cmp #R cmp #R
beq RUN // Run the program! Forget the rest beq RUN // Run the program! Forget the rest
stx MemMap.SHELL.L // Clear input value (X=0) stx MemMap.SHELL.L // Clear input value (X=0)
stx MemMap.SHELL.H stx MemMap.SHELL.H
sty MemMap.SHELL.YSAV // Save Y for comparison sty MemMap.SHELL.YSAV // Save Y for comparison
// Here we're trying to parse a new hex value // Here we're trying to parse a new hex value
NEXTHEX: NEXTHEX:
lda MemMap.SHELL.buffer,y // Get character for hex test lda MemMap.SHELL.buffer,y // Get character for hex test
eor #$30 // Map digits to 0-9 eor #$30 // Map digits to 0-9
cmp #9+1 // Is it a decimal digit? cmp #9+1 // Is it a decimal digit?
bcc DIG // Yes! bcc DIG // Yes!
adc #$88 // Map letter "A"-"F" to $FA-FF adc #$88 // Map letter "A"-"F" to $FA-FF
cmp #$FA // Hex letter? cmp #$FA // Hex letter?
bcc NOTHEX // No! Character not hex bcc NOTHEX // No! Character not hex
DIG: DIG:
asl asl
asl // Hex digit to MSD of A asl // Hex digit to MSD of A
asl asl
asl asl
ldx #4 // Shift count ldx #4 // Shift count
HEXSHIFT: asl // Hex digit left, MSB to carry HEXSHIFT:
rol MemMap.SHELL.L // Rotate into LSD asl // Hex digit left, MSB to carry
rol MemMap.SHELL.H // Rotate into MSD's rol MemMap.SHELL.L // Rotate into LSD
dex // Done 4 shifts? rol MemMap.SHELL.H // Rotate into MSD's
bne HEXSHIFT // No, loop dex // Done 4 shifts?
iny // Advance text index bne HEXSHIFT // No, loop
bne NEXTHEX // Always taken iny // Advance text index
bne NEXTHEX // Always taken
NOTHEX: cpy MemMap.SHELL.YSAV //Was at least 1 hex digit given? NOTHEX: cpy MemMap.SHELL.YSAV //Was at least 1 hex digit given?
bne !+ // No! Ignore all, start from scratch bne !+ // No! Ignore all, start from scratch
rts rts
!: !:
bit MemMap.SHELL.MODE //Test MODE byte bit MemMap.SHELL.MODE //Test MODE byte
bvc NOTSTOR // B6=0 is STOR, 1 is XAM or BLOCK XAM bvc NOTSTOR // B6=0 is STOR, 1 is XAM or BLOCK XAM
// STOR mode, save LSD of new hex byte // STOR mode, save LSD of new hex byte
lda MemMap.SHELL.L // LSD's of hex data lda MemMap.SHELL.L // LSD's of hex data
sta (MemMap.SHELL.STL,X) //Store current 'store index'(X=0) sta (MemMap.SHELL.STL,X) //Store current 'store index'(X=0)
inc MemMap.SHELL.STL //Increment store index. inc MemMap.SHELL.STL //Increment store index.
bne NEXTITEM // No carry! bne NEXTITEM // No carry!
inc MemMap.SHELL.STH // Add carry to 'store index' high inc MemMap.SHELL.STH // Add carry to 'store index' high
TONEXTITEM: jmp NEXTITEM //Get next command item. TONEXTITEM:
jmp NEXTITEM //Get next command item.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// RUN user's program from last opened location // RUN user's program from last opened location
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
RUN: jmp (MemMap.SHELL.XAML) // Run user's program RUN: jmp (MemMap.SHELL.XAML) // Run user's program
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
// We're not in Store mode // We're not in Store mode
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NOTSTOR: bmi XAMNEXT // B7 = 0 for XAM, 1 for BLOCK XAM NOTSTOR:
bmi XAMNEXT // B7 = 0 for XAM, 1 for BLOCK XAM
// We're in XAM mode now // We're in XAM mode now
ldx #2 // Copy 2 bytes ldx #2 // Copy 2 bytes
SETADR: lda MemMap.SHELL.L-1,X // Copy hex data to SETADR: lda MemMap.SHELL.L-1,X // Copy hex data to
sta MemMap.SHELL.STL-1,X // 'store index' sta MemMap.SHELL.STL-1,X // 'store index'
sta MemMap.SHELL.XAML-1,X // and to 'XAM index' sta MemMap.SHELL.XAML-1,X // and to 'XAM index'
dex // Next of 2 bytes dex // Next of 2 bytes
bne SETADR // Loop unless X = 0 bne SETADR // Loop unless X = 0
// Print address and data from this address, fall through next BNE. // Print address and data from this address, fall through next BNE.
NXTPRNT: bne PRDATA // NE means no address to print NXTPRNT:
lda #CR // Print CR first bne PRDATA // NE means no address to print
PrintChar() lda #CR // Print CR first
lda MemMap.SHELL.XAMH // Output high-order byte of address PrintChar()
jsr PRBYTE lda MemMap.SHELL.XAMH // Output high-order byte of address
lda MemMap.SHELL.XAML // Output low-order byte of address jsr PRBYTE
jsr PRBYTE lda MemMap.SHELL.XAML // Output low-order byte of address
lda #':' // Print colon jsr PRBYTE
PrintChar() lda #':' // Print colon
PrintChar()
PRDATA: lda #' ' // Print space PRDATA: lda #' ' // Print space
PrintChar() PrintChar()
lda (MemMap.SHELL.XAML,X) // Get data from address (X=0) lda (MemMap.SHELL.XAML,X) // Get data from address (X=0)
jsr PRBYTE // Output it in hex format jsr PRBYTE // Output it in hex format
XAMNEXT: stx MemMap.SHELL.MODE // 0 -> MODE (XAM mode). XAMNEXT:
lda MemMap.SHELL.XAML // See if there's more to print stx MemMap.SHELL.MODE // 0 -> MODE (XAM mode).
cmp MemMap.SHELL.L lda MemMap.SHELL.XAML // See if there's more to print
lda MemMap.SHELL.XAMH cmp MemMap.SHELL.L
sbc MemMap.SHELL.H lda MemMap.SHELL.XAMH
bcs TONEXTITEM // Not less! No more data to output sbc MemMap.SHELL.H
bcs TONEXTITEM // Not less! No more data to output
inc MemMap.SHELL.XAML // Increment 'examine index' inc MemMap.SHELL.XAML // Increment 'examine index'
bne MOD8CHK // No carry! bne MOD8CHK // No carry!
inc MemMap.SHELL.XAMH inc MemMap.SHELL.XAMH
MOD8CHK: lda MemMap.SHELL.XAML // If address MOD 8 = 0 start new line MOD8CHK:
and #%00000111 lda MemMap.SHELL.XAML // If address MOD 8 = 0 start new line
bpl NXTPRNT // Always taken. and #%00000111
bpl NXTPRNT // Always taken.
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Subroutine to print a byte in A in hex form (destructive) // Subroutine to print a byte in A in hex form (destructive)
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
PRBYTE: pha // Save A for LSD PRBYTE:
lsr pha // Save A for LSD
lsr lsr
lsr // MSD to LSD position lsr
lsr lsr // MSD to LSD position
jsr PRHEX // Output hex digit lsr
pla // Restore A jsr PRHEX // Output hex digit
pla // Restore A
// Fall through to print hex routine // Fall through to print hex routine
@ -246,14 +249,14 @@ PRBYTE: pha // Save A for LSD
// Subroutine to print a hexadecimal digit // Subroutine to print a hexadecimal digit
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
PRHEX: and #%00001111 // Mask LSD for hex print PRHEX: and #%00001111 // Mask LSD for hex print
ora #'0' // Add "0" ora #'0' // Add "0"
cmp #'9'+1 // Is it a decimal digit? cmp #'9'+1 // Is it a decimal digit?
bcc !+ // Yes! output it bcc !+ // Yes! output it
adc #6 // Add offset for letter A-F adc #6 // Add offset for letter A-F
!: !:
PrintChar() PrintChar()
rts rts
} }
@ -263,31 +266,31 @@ PRHEX: and #%00001111 // Mask LSD for hex prin
// ======================================================== // ========================================================
* = * "WozShell Data" * = * "WozShell Data"
module_type: .byte Module.TYPES.PROG module_type: .byte Module.TYPES.PROG
version: .byte 1, 2, 0 version: .byte 1, 2, 0
.encoding "screencode_mixed" .encoding "screencode_mixed"
module_name: module_name:
.text "woz-shell" .text "woz-shell"
.byte 0 .byte 0
helpString: helpString:
.text "----------------------" .text "----------------------"
.byte $8e .byte $8e
.text "h : this help" .text "h : this help"
.byte $8e .byte $8e
.text "r : hard reset" .text "r : hard reset"
.byte $8e .byte $8e
.text "v : modue versions" .text "v : modue versions"
.byte $8e .byte $8e
.text "----------------------" .text "----------------------"
.byte $8e, 0 .byte $8e, 0
aboutString: aboutString:
.text "woz64 mon - v 0.1.5" .text "woz64 mon - v 0.1.5"
.byte $8e, 0 .byte $8e, 0
lineString: lineString:
.text "----------------------------------------" .text "----------------------------------------"
.byte $8e, 0 .byte $8e, 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"