From c8ba619d332e238d2d776e4a759a80ce0c959414 Mon Sep 17 00:00:00 2001 From: stid Date: Sun, 12 Jan 2020 17:24:10 -0800 Subject: [PATCH] Standardize indent --- core/init.asm | 47 +++--- core/keyboard.asm | 262 +++++++++++++++++--------------- libs/math.asm | 32 ++-- libs/memory.asm | 176 ++++++++++----------- libs/print.asm | 80 +++++----- main.asm | 94 ++++++------ progs/woz_shell.asm | 363 ++++++++++++++++++++++---------------------- 7 files changed, 538 insertions(+), 516 deletions(-) diff --git a/core/init.asm b/core/init.asm index 9a416f4..f87d2f3 100644 --- a/core/init.asm +++ b/core/init.asm @@ -22,15 +22,15 @@ // Module Init. // -------------------------------------------------------- init: { - // Init All Modules - jsr Memory.init - jsr Math.init - jsr Print.init - jsr Keyboard.init - jsr Screen.init - jsr WozShell.init - jsr Module.init - rts + // Init All Modules + jsr Memory.init + jsr Math.init + jsr Print.init + jsr Keyboard.init + jsr Screen.init + jsr WozShell.init + jsr Module.init + rts } // -------------------------------------------------------- @@ -38,32 +38,31 @@ init: { // Print debug info. // -------------------------------------------------------- toDebug: { - // Debug All Modules - ModuleToDebug(module_type, module_name, version) - jsr Keyboard.toDebug - jsr Screen.toDebug - jsr Module.toDebug - jsr Memory.toDebug - jsr Print.toDebug - jsr Math.toDebug - jsr WozShell.toDebug - rts + // Debug All Modules + ModuleToDebug(module_type, module_name, version) + jsr Keyboard.toDebug + jsr Screen.toDebug + jsr Module.toDebug + jsr Memory.toDebug + jsr Print.toDebug + jsr Math.toDebug + jsr WozShell.toDebug + rts } - // ======================================================== // ////// DATA //////////////////////////////////////////// // ======================================================== * = * "Init Core Data" -module_type: .byte Module.TYPES.CORE -version: .byte 1, 1, 0 +module_type: .byte Module.TYPES.CORE +version: .byte 1, 1, 0 .encoding "screencode_mixed" module_name: - .text "init" - .byte 0 + .text "init" + .byte 0 #import "../core/mem_map.asm" diff --git a/core/keyboard.asm b/core/keyboard.asm index 86a55a6..db40287 100644 --- a/core/keyboard.asm +++ b/core/keyboard.asm @@ -29,24 +29,24 @@ // Module Init. // -------------------------------------------------------- init: { - lda #64 - sta MemMap.KEYBOARD.SYS_Lstx - sta MemMap.KEYBOARD.SYS_Sfdx + lda #64 + sta MemMap.KEYBOARD.SYS_Lstx + sta MemMap.KEYBOARD.SYS_Sfdx - lda #cSYS_DelayValue - sta MemMap.KEYBOARD.SYS_Delay + lda #cSYS_DelayValue + sta MemMap.KEYBOARD.SYS_Delay - lda #6 - sta MemMap.KEYBOARD.SYS_Kount + lda #6 + sta MemMap.KEYBOARD.SYS_Kount - lda #0 - sta MemMap.KEYBOARD.SYS_Shflag - sta MemMap.KEYBOARD.SYS_Lstshf + lda #0 + sta MemMap.KEYBOARD.SYS_Shflag + sta MemMap.KEYBOARD.SYS_Lstshf - sta MemMap.KEYBOARD.SYS_Ndx + sta MemMap.KEYBOARD.SYS_Ndx - lda #10 - sta MemMap.KEYBOARD.SYS_Xmax + lda #10 + sta MemMap.KEYBOARD.SYS_Xmax // Clone self altering Methods to RAM MemoryClone(cloneStart, cloneEnd, $1000) @@ -58,8 +58,8 @@ init: { // Print debug info. // -------------------------------------------------------- toDebug: { - ModuleToDebug(module_type, module_name, version) - rts + ModuleToDebug(module_type, module_name, version) + rts } // ======================================================== @@ -67,7 +67,7 @@ toDebug: { // ======================================================== KeyMapVec: - .word KeyMap1, KeyMap2, KeyMap3, KeyMap4 + .word KeyMap1, KeyMap2, KeyMap3, KeyMap4 // Unshifted KeyMap1: @@ -145,139 +145,151 @@ cloneStart: // // Key here is in A // -------------------------------------------------------- .pseudopc $1000 { -ReadKeyb: - lda #KeyMap1 - sta @SMC_Vec + 1 +ReadKeyb: { + lda #KeyMap1 + sta @SMC_Vec + 1 // Clear Shift Flag - lda #$40 - sta MemMap.KEYBOARD.SYS_Sfdx + lda #$40 + sta MemMap.KEYBOARD.SYS_Sfdx - lda #0 - sta MemMap.KEYBOARD.SYS_Shflag + lda #0 + sta MemMap.KEYBOARD.SYS_Shflag - sta CIA1_KeybWrite - ldx CIA1_KeybRead - cpx #$FF - beq @Cleanup + sta CIA1_KeybWrite + ldx CIA1_KeybRead + cpx #$FF + beq @Cleanup - ldy #$00 + ldy #$00 - lda #7 - sta MemMap.KEYBOARD.KeyR + lda #7 + sta MemMap.KEYBOARD.KeyR - lda #cKeybW_Row1 - sta @SMC_Row + 1 -@SMC_Row: lda #0 + lda #cKeybW_Row1 + sta @SMC_Row + 1 + @SMC_Row: + lda #0 - sta CIA1_KeybWrite + sta CIA1_KeybWrite -@Loop_Debounce: - lda CIA1_KeybRead - cmp CIA1_KeybRead - bne @Loop_Debounce + @Loop_Debounce: + lda CIA1_KeybRead + cmp CIA1_KeybRead + bne @Loop_Debounce - ldx #7 -@Loop_Col: lsr - bcs @NextKey - sta @SMC_A + 1 + ldx #7 + @Loop_Col: + lsr + 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 - cmp #$05 - bcs @NotShift // Not Shift + cmp #$05 + bcs @NotShift // Not Shift - cmp #$03 - beq @NotShift // Stop Key + cmp #$03 + beq @NotShift // Stop Key // Accumulate shift key types (SHIFT=1, COMM=2, CTRL=4) - ora MemMap.KEYBOARD.SYS_Shflag - sta MemMap.KEYBOARD.SYS_Shflag - bpl @SMC_A + ora MemMap.KEYBOARD.SYS_Shflag + sta MemMap.KEYBOARD.SYS_Shflag + 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 - bpl @Loop_Col + bpl @Loop_Col sec - rol @SMC_Row + 1 - dec MemMap.KEYBOARD.KeyR - bpl @SMC_Row + rol @SMC_Row + 1 + dec MemMap.KEYBOARD.KeyR + bpl @SMC_Row - jmp @ProcKeyImg + jmp @ProcKeyImg // Handles the key repeat -@Process: ldy MemMap.KEYBOARD.SYS_Sfdx -@SMC_Key: lda $FFFF,Y + @Process: + ldy MemMap.KEYBOARD.SYS_Sfdx + @SMC_Key: + lda $FFFF,Y tax - cpy MemMap.KEYBOARD.SYS_Lstx - beq @SameKey + cpy MemMap.KEYBOARD.SYS_Lstx + beq @SameKey - ldy #cSYS_DelayValue - sty MemMap.KEYBOARD.SYS_Delay // Repeat delay counter - bne @Cleanup + ldy #cSYS_DelayValue + sty MemMap.KEYBOARD.SYS_Delay // Repeat delay counter + bne @Cleanup -@SameKey: and #$7F - ldy MemMap.KEYBOARD.SYS_Delay - beq @EndDelay - dec MemMap.KEYBOARD.SYS_Delay - bne @Exit + @SameKey: + and #$7F + ldy MemMap.KEYBOARD.SYS_Delay + beq @EndDelay + dec MemMap.KEYBOARD.SYS_Delay + bne @Exit -@EndDelay: dec MemMap.KEYBOARD.SYS_Kount - bne @Exit + @EndDelay: + dec MemMap.KEYBOARD.SYS_Kount + bne @Exit - ldy #$04 - sty MemMap.KEYBOARD.SYS_Kount - ldy MemMap.KEYBOARD.SYS_Ndx + ldy #$04 + sty MemMap.KEYBOARD.SYS_Kount + ldy MemMap.KEYBOARD.SYS_Ndx dey - bpl @Exit + bpl @Exit // Updates the previous key and shift storage -@Cleanup: ldy MemMap.KEYBOARD.SYS_Sfdx - sty MemMap.KEYBOARD.SYS_Lstx - ldy MemMap.KEYBOARD.SYS_Shflag - sty MemMap.KEYBOARD.SYS_Lstshf + @Cleanup: + ldy MemMap.KEYBOARD.SYS_Sfdx + sty MemMap.KEYBOARD.SYS_Lstx + ldy MemMap.KEYBOARD.SYS_Shflag + sty MemMap.KEYBOARD.SYS_Lstshf - cpx #$FF - beq @Exit + cpx #$FF + beq @Exit txa - ldx MemMap.KEYBOARD.SYS_Ndx - cpx MemMap.KEYBOARD.SYS_Xmax - bcs @Exit + ldx MemMap.KEYBOARD.SYS_Ndx + cpx MemMap.KEYBOARD.SYS_Xmax + bcs @Exit - sta MemMap.KEYBOARD.SYS_Keyd,X + sta MemMap.KEYBOARD.SYS_Keyd,X inx - stx MemMap.KEYBOARD.SYS_Ndx + stx MemMap.KEYBOARD.SYS_Ndx -@Exit: lda #$7F - sta CIA1_KeybWrite + @Exit: + lda #$7F + sta CIA1_KeybWrite rts -@ProcKeyImg: - lda MemMap.KEYBOARD.SYS_Shflag - cmp #$03 // C= + SHIFT - bne @SetDecodeTable - cmp MemMap.KEYBOARD.SYS_Lstshf - beq @Exit + @ProcKeyImg: + lda MemMap.KEYBOARD.SYS_Shflag + cmp #$03 // C= + SHIFT + bne @SetDecodeTable + cmp MemMap.KEYBOARD.SYS_Lstshf + beq @Exit -@SetDecodeTable: + @SetDecodeTable: asl - cmp #8 // CONTROL - bcc @Cont - lda #$06 -@Cont: tax - lda KeyMapVec,X - sta @SMC_Key + 1 - lda KeyMapVec + 1,X - sta @SMC_Key + 2 - jmp @Process + cmp #8 // CONTROL + bcc @Cont + lda #$06 + @Cont: tax + lda KeyMapVec,X + sta @SMC_Key + 1 + lda KeyMapVec + 1,X + sta @SMC_Key + 2 + jmp @Process +} // -------------------------------------------------------- // GetKey - @@ -287,25 +299,31 @@ ReadKeyb: // Result: // A = Pressed key code or 0 // -------------------------------------------------------- -GetKey: lda MemMap.KEYBOARD.SYS_Ndx - bne @IsKey +GetKey: { -@NoKey: lda #255 // Null + lda MemMap.KEYBOARD.SYS_Ndx + bne @IsKey + + @NoKey: + lda #255 // Null sec rts -@IsKey: ldy MemMap.KEYBOARD.SYS_Keyd - ldx #0 -@Loop: lda MemMap.KEYBOARD.SYS_Keyd + 1,X - sta MemMap.KEYBOARD.SYS_Keyd,X + @IsKey: + ldy MemMap.KEYBOARD.SYS_Keyd + ldx #0 + @Loop: + lda MemMap.KEYBOARD.SYS_Keyd + 1,X + sta MemMap.KEYBOARD.SYS_Keyd,X inx - cpx MemMap.KEYBOARD.SYS_Ndx - bne @Loop - dec MemMap.KEYBOARD.SYS_Ndx + cpx MemMap.KEYBOARD.SYS_Ndx + bne @Loop + dec MemMap.KEYBOARD.SYS_Ndx tya clc rts -} + +}} * = * "Keyboard Ram End" @@ -316,13 +334,13 @@ cloneEnd: // ======================================================== * = * "Keyboard Module Data" -module_type: .byte Module.TYPES.CORE -version: .byte 1, 1, 0 +module_type: .byte Module.TYPES.CORE +version: .byte 1, 1, 0 .encoding "screencode_mixed" module_name: - .text "keyboard" - .byte 0 + .text "keyboard" + .byte 0 #import "../core/mem_map.asm" diff --git a/libs/math.asm b/libs/math.asm index d5f7070..4050fc1 100644 --- a/libs/math.asm +++ b/libs/math.asm @@ -26,8 +26,8 @@ init: { // Print debug info. // -------------------------------------------------------- toDebug: { - ModuleToDebug(module_type, module_name, version) - rts + ModuleToDebug(module_type, module_name, version) + rts } // -------------------------------------------------------- @@ -47,20 +47,20 @@ multiply: { txa pha - lda #$00 - ldx #$08 + lda #$00 + ldx #$08 clc - m0: bcc.r m1 + m0: bcc.r m1 clc - adc MemMap.MATH.factor2 - m1: ror - ror MemMap.MATH.factor1 + adc MemMap.MATH.factor2 + m1: ror + ror MemMap.MATH.factor1 dex - bpl.r m0 - ldx MemMap.MATH.factor1 + bpl.r m0 + ldx MemMap.MATH.factor1 - sta MemMap.MATH.result - stx MemMap.MATH.result+1 + sta MemMap.MATH.result + stx MemMap.MATH.result+1 pla tax @@ -75,13 +75,13 @@ multiply: { // ======================================================== * = * "Math Lib Data" -module_type: .byte Module.TYPES.LIB -version: .byte 1, 1, 0 +module_type: .byte Module.TYPES.LIB +version: .byte 1, 1, 0 .encoding "screencode_mixed" module_name: - .text "math" - .byte 0 + .text "math" + .byte 0 #import "../core/mem_map.asm" diff --git a/libs/memory.asm b/libs/memory.asm index e7beeb4..9818bc5 100644 --- a/libs/memory.asm +++ b/libs/memory.asm @@ -18,22 +18,22 @@ // dest = Destination Memory pointer // -------------------------------------------------------- .macro MemoryClone(from, to, dest) { - lda #from - sta MemMap.MEMORY.from+1 + lda #from + sta MemMap.MEMORY.from+1 - lda #dest - sta MemMap.MEMORY.dest+1 + lda #dest + sta MemMap.MEMORY.dest+1 - lda #to-from - sta MemMap.MEMORY.size + lda #to-from + sta MemMap.MEMORY.size - jsr Memory.clone + jsr Memory.clone } // -------------------------------------------------------- @@ -46,18 +46,18 @@ // fillByte = Byte used to fill the range // -------------------------------------------------------- .macro MemoryFill(from, to, fillByte) { - lda #from - sta MemMap.MEMORY.from+1 + lda #from + sta MemMap.MEMORY.from+1 - lda #to-from - sta MemMap.MEMORY.size + lda #to-from + sta MemMap.MEMORY.size - lda #fillByte - jsr Memory.fill + lda #fillByte + jsr Memory.fill } // -------------------------------------------------------- @@ -69,17 +69,17 @@ // to = End Memory Pointer to fill // -------------------------------------------------------- .macro MemoryClear(from, to) { - lda #from - sta MemMap.MEMORY.from+1 + lda #from + sta MemMap.MEMORY.from+1 - lda #to-from - sta MemMap.MEMORY.size + lda #to-from + sta MemMap.MEMORY.size - jsr Memory.clear + jsr Memory.clear } @@ -97,7 +97,7 @@ // Module Init. // -------------------------------------------------------- init: { - rts + rts } // -------------------------------------------------------- @@ -105,8 +105,8 @@ init: { // Print debug info. // -------------------------------------------------------- toDebug: { - ModuleToDebug(module_type, module_name, version) - rts + ModuleToDebug(module_type, module_name, version) + rts } @@ -123,32 +123,32 @@ toDebug: { // copy // -------------------------------------------------------- clone: { - stx MemMap.MEMORY.tmpX - sty MemMap.MEMORY.tmpY - sei - ldy #0 - ldx MemMap.MEMORY.size - beq md2 - md1: lda (MemMap.MEMORY.from),y // move a page at a time - sta (MemMap.MEMORY.dest),y - iny - bne md1 - inc MemMap.MEMORY.from+1 - inc MemMap.MEMORY.dest+1 - dex - bne md1 - md2: ldx MemMap.MEMORY.size+1 - beq md4 - md3: lda (MemMap.MEMORY.from),y // move the remaining bytes - sta (MemMap.MEMORY.dest),y - iny - dex - bne md3 - cli - md4: - ldx MemMap.MEMORY.tmpX - ldy MemMap.MEMORY.tmpY - rts + stx MemMap.MEMORY.tmpX + sty MemMap.MEMORY.tmpY + sei + ldy #0 + ldx MemMap.MEMORY.size + beq md2 + md1: lda (MemMap.MEMORY.from),y // move a page at a time + sta (MemMap.MEMORY.dest),y + iny + bne md1 + inc MemMap.MEMORY.from+1 + inc MemMap.MEMORY.dest+1 + dex + bne md1 + md2: ldx MemMap.MEMORY.size+1 + beq md4 + md3: lda (MemMap.MEMORY.from),y // move the remaining bytes + sta (MemMap.MEMORY.dest),y + iny + dex + bne md3 + cli + md4: + ldx MemMap.MEMORY.tmpX + ldy MemMap.MEMORY.tmpY + rts } // -------------------------------------------------------- @@ -163,31 +163,31 @@ clone: { // A = The byte to fill memory with // -------------------------------------------------------- fill: { - stx MemMap.MEMORY.tmpX - sty MemMap.MEMORY.tmpY - sei - ldy #0 - ldx MemMap.MEMORY.size - beq md2 - md1: - sta (MemMap.MEMORY.dest),y - iny - bne md1 - inc MemMap.MEMORY.dest+1 - dex - bne md1 - md2: ldx MemMap.MEMORY.size+1 - beq md4 - md3: - sta (MemMap.MEMORY.dest),y - iny - dex - bne md3 - cli - md4: - ldx MemMap.MEMORY.tmpX - ldy MemMap.MEMORY.tmpY - rts + stx MemMap.MEMORY.tmpX + sty MemMap.MEMORY.tmpY + sei + ldy #0 + ldx MemMap.MEMORY.size + beq md2 + md1: + sta (MemMap.MEMORY.dest),y + iny + bne md1 + inc MemMap.MEMORY.dest+1 + dex + bne md1 + md2: ldx MemMap.MEMORY.size+1 + beq md4 + md3: + sta (MemMap.MEMORY.dest),y + iny + dex + bne md3 + cli + md4: + ldx MemMap.MEMORY.tmpX + ldy MemMap.MEMORY.tmpY + rts } // Clear Memory with 0 @@ -206,8 +206,8 @@ fill: { // clean // -------------------------------------------------------- clean: { - lda #00 - jmp Memory.fill + lda #00 + jmp Memory.fill } diff --git a/libs/print.asm b/libs/print.asm index c2a3ade..2acd704 100644 --- a/libs/print.asm +++ b/libs/print.asm @@ -10,17 +10,17 @@ // ======================================================== .macro PrintLine(stringAddr) { - lda #stringAddr // High byte - jsr Print.printLine + lda #stringAddr // High byte + jsr Print.printLine } .macro PrintChar() { - jsr Print.printPetChar + jsr Print.printPetChar } .macro PrintNewLine() { - jsr Screen.screenNewLine + jsr Screen.screenNewLine } @@ -78,17 +78,17 @@ printPetChar: { // X = low byte string address // -------------------------------------------------------- printLine: { - ldy #$00 - sta MemMap.SCREEN.TempStringPointer - stx MemMap.SCREEN.TempStringPointer+1 + ldy #$00 + sta MemMap.SCREEN.TempStringPointer + stx MemMap.SCREEN.TempStringPointer+1 printLoop: - lda (MemMap.SCREEN.TempStringPointer), y - cmp #0 - beq exit - jsr Screen.sendChar - jmp printLoop + lda (MemMap.SCREEN.TempStringPointer), y + cmp #0 + beq exit + jsr Screen.sendChar + jmp printLoop exit: - rts + rts } // -------------------------------------------------------- @@ -103,27 +103,29 @@ printLine: { // X = lns ascii char result // -------------------------------------------------------- byteToHex: { - pha //save byte - and #%00001111 //extract lsn - tax //save it - pla //recover byte - lsr //extract... - lsr //msn - lsr - lsr - pha //save msn - txa //lsn - jsr binhex1 //generate ascii lsn - tax //save - pla //get msn & fall thru - // - // convert nybble to hex ascii equivalent... - binhex1: cmp #$0a - bcc binhex2 //in decimal range - sbc #$09 //hex compensate - rts - binhex2: eor #%00110000 //finalize nybble - rts //done + pha //save byte + and #%00001111 //extract lsn + tax //save it + pla //recover byte + lsr //extract... + lsr //msn + lsr + lsr + pha //save msn + txa //lsn + jsr binhex1 //generate ascii lsn + tax //save + pla //get msn & fall thru + // + // convert nybble to hex ascii equivalent... + binhex1: + cmp #$0a + bcc binhex2 //in decimal range + sbc #$09 //hex compensate + rts + binhex2: + eor #%00110000 //finalize nybble + rts //done } // -------------------------------------------------------- @@ -197,13 +199,13 @@ petCharToScreenChar: { // ======================================================== * = * "Print Lib Data" -module_type: .byte Module.TYPES.LIB -version: .byte 1, 0, 0 +module_type: .byte Module.TYPES.LIB +version: .byte 1, 0, 0 .encoding "screencode_mixed" module_name: - .text "print" - .byte 0 + .text "print" + .byte 0 #import "../core/mem_map.asm" diff --git a/main.asm b/main.asm index b8e00c9..eaa4c94 100644 --- a/main.asm +++ b/main.asm @@ -20,7 +20,7 @@ .const RASTER_LINE = $d012 .const INTERRUPT_CTRL = $dc0d .const NMSK_INTERRUPT_CTRL = $dd0d -.const TIMER_A_CTRL = $DC0E +.const TIMER_A_CTRL = $DC0E //------------------------------------------------------------------------------------ .word coldstart // coldstart vector @@ -39,78 +39,80 @@ //------------------------------------------------------------------------------------ * = * "Kernel Start" -coldstart: - ldx #$FF +coldstart: { + ldx #$FF sei txs cld - stx SCRN_CTRL // Set Screen Bits - jsr INIT_IRQ // Prepare IRQ - jsr INIT_MEM // Init memory. Rewrite this routine to speed up boot process. - jsr INIT_IO // Init I/O - jsr INIT_VID // Init video + stx SCRN_CTRL // Set Screen Bits + jsr INIT_IRQ // Prepare IRQ + jsr INIT_MEM // Init memory. Rewrite this routine to speed up boot process. + jsr INIT_IO // Init I/O + jsr INIT_VID // Init video cli +} * = * "App Start" //------------------------------------------------------------------------------------ -start: - jsr initApp; - jsr WozShell.start +start: { + jsr initApp; + jsr WozShell.start + loop: + lda #$FF + Raster: + cmp RASTER_LINE // Raster done? + bne Raster + jsr Keyboard.ReadKeyb + jsr Keyboard.GetKey + bcs loop -loop: - lda #$FF -Raster: cmp RASTER_LINE // Raster done? - bne Raster - jsr Keyboard.ReadKeyb - jsr Keyboard.GetKey - bcs loop + cmp #CR + beq execute - cmp #CR - beq execute - - cmp #BS - beq backspace -inputChar: - jsr WozShell.push // Char in Buffer + cmp #BS + beq backspace + inputChar: + jsr WozShell.push // Char in Buffer PrintChar() - jmp loop -backspace: - jsr WozShell.backspace + jmp loop + backspace: + jsr WozShell.backspace PrintChar() - jmp loop + jmp loop -execute: - jsr WozShell.push // CR in Buffer - jsr Screen.screenNewLine - jsr WozShell.exec - jsr Screen.screenNewLine - jsr WozShell.clear - jmp loop + execute: + jsr WozShell.push // CR in Buffer + jsr Screen.screenNewLine + jsr WozShell.exec + jsr Screen.screenNewLine + jsr WozShell.clear + jmp loop +} //------------------------------------------------------------------------------------ initApp: { sei - lda #$7f - 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 + lda #$7f + 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 // stop it. - 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 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. // we don't want that to happen. // Disable 0e TIMER - lda #254 - and TIMER_A_CTRL - sta TIMER_A_CTRL + lda #254 + and TIMER_A_CTRL + sta TIMER_A_CTRL ScreenClearColorRam($00) ScreenClear(' ') ScreenSetBorderColor(BORDER_COLOR) ScreenSetBackgroundColor(MAIN_COLOR) - jsr Init.init + jsr Init.init cli rts } @@ -118,8 +120,6 @@ initApp: { //------------------------------------------------------------------------------------ * = * "Kernel Data" - - * = $9FFF "EpromFiller" .byte 0 diff --git a/progs/woz_shell.asm b/progs/woz_shell.asm index c1b6d0f..63f6356 100644 --- a/progs/woz_shell.asm +++ b/progs/woz_shell.asm @@ -11,8 +11,8 @@ // ////// CONSTANTS /////////////////////////////////////// // ======================================================== -.const CR = $0d -.const R = $52 +.const CR = $0d +.const R = $52 // ======================================================== @@ -22,223 +22,226 @@ clear: init: { - - lda #-1 - sta MemMap.SHELL.pos - rts + lda #-1 + sta MemMap.SHELL.pos + rts } start: { - PrintLine(lineString) - PrintLine(aboutString) - PrintLine(lineString) - rts + PrintLine(lineString) + PrintLine(aboutString) + PrintLine(lineString) + rts } toDebug: { - ModuleToDebug(module_type, module_name, version) - rts + ModuleToDebug(module_type, module_name, version) + rts } push: { - ldy MemMap.SHELL.pos - iny - cpy #127 - beq.r done - sty MemMap.SHELL.pos - sta MemMap.SHELL.buffer, y - done: - rts + ldy MemMap.SHELL.pos + iny + cpy #127 + beq.r done + sty MemMap.SHELL.pos + sta MemMap.SHELL.buffer, y + done: + rts } backspace: { - ldy MemMap.SHELL.pos - cpy #-1 - beq done - dey - sty MemMap.SHELL.pos - done: - rts + ldy MemMap.SHELL.pos + cpy #-1 + beq done + dey + sty MemMap.SHELL.pos + done: + rts } exec: { - lda MemMap.SHELL.buffer // Check first char - cmp #'!' - beq stidExec // if ! is stid mon command - jmp wozExec // Otherwise exec Woz - // Expect exec functions to RTS + lda MemMap.SHELL.buffer // Check first char + cmp #'!' + beq stidExec // if ! is stid mon command + jmp wozExec // Otherwise exec Woz + // Expect exec functions to RTS } stidExec: { - ldy #1 + ldy #1 - lda MemMap.SHELL.buffer, y + lda MemMap.SHELL.buffer, y - cmp #$48 // H - beq cmdHelp + cmp #$48 // H + beq cmdHelp - cmp #$52 // R - beq cmdReset + cmp #$52 // R + beq cmdReset - cmp #$56 // Z - beq cmdZeroPageInfo + cmp #$56 // Z + beq cmdZeroPageInfo + done: + rts + // STID Commands + cmdHelp: + PrintLine(helpString) + jmp done + cmdReset: + jmp $fce2 // SYS 64738 -done: - rts - -// STID Commands -cmdHelp: - PrintLine(helpString) - jmp done - -cmdReset: - jmp $fce2 // SYS 64738 - -cmdZeroPageInfo: - jsr Init.toDebug - jmp done + cmdZeroPageInfo: + jsr Init.toDebug + jmp done } // WOZ MONITOR FLOW - FROM APPLE1 wozExec: { - ldy #-1 - lda #0 - tax - SETSTOR: - asl - SETMODE: - cmp #0 - beq.r !+ - eor #%10000000 + ldy #-1 + lda #0 + tax + SETSTOR: + asl + SETMODE: + cmp #0 + beq.r !+ + eor #%10000000 !: - sta MemMap.SHELL.MODE + sta MemMap.SHELL.MODE - BLSKIP: iny + BLSKIP: iny - NEXTITEM: - lda MemMap.SHELL.buffer,Y //Get character - cmp #CR - bne.r CONT // We're done if it's CR! - rts - CONT: - cmp #'.' - bcc BLSKIP // Ignore everything below "."! - beq SETMODE // Set BLOCK XAM mode ("." = $AE) - cmp #':' - beq SETSTOR // Set STOR mode! $BA will become $7B - cmp #R - beq RUN // Run the program! Forget the rest - stx MemMap.SHELL.L // Clear input value (X=0) - stx MemMap.SHELL.H - sty MemMap.SHELL.YSAV // Save Y for comparison + NEXTITEM: + lda MemMap.SHELL.buffer,Y //Get character + cmp #CR + bne.r CONT // We're done if it's CR! + rts + CONT: + cmp #'.' + bcc BLSKIP // Ignore everything below "."! + beq SETMODE // Set BLOCK XAM mode ("." = $AE) + cmp #':' + beq SETSTOR // Set STOR mode! $BA will become $7B + cmp #R + beq RUN // Run the program! Forget the rest + stx MemMap.SHELL.L // Clear input value (X=0) + stx MemMap.SHELL.H + sty MemMap.SHELL.YSAV // Save Y for comparison // Here we're trying to parse a new hex value - NEXTHEX: - lda MemMap.SHELL.buffer,y // Get character for hex test - eor #$30 // Map digits to 0-9 - cmp #9+1 // Is it a decimal digit? - bcc DIG // Yes! - adc #$88 // Map letter "A"-"F" to $FA-FF - cmp #$FA // Hex letter? - bcc NOTHEX // No! Character not hex + NEXTHEX: + lda MemMap.SHELL.buffer,y // Get character for hex test + eor #$30 // Map digits to 0-9 + cmp #9+1 // Is it a decimal digit? + bcc DIG // Yes! + adc #$88 // Map letter "A"-"F" to $FA-FF + cmp #$FA // Hex letter? + bcc NOTHEX // No! Character not hex - DIG: - asl - asl // Hex digit to MSD of A - asl - asl + DIG: + asl + asl // Hex digit to MSD of A + asl + asl - ldx #4 // Shift count - HEXSHIFT: asl // Hex digit left, MSB to carry - rol MemMap.SHELL.L // Rotate into LSD - rol MemMap.SHELL.H // Rotate into MSD's - dex // Done 4 shifts? - bne HEXSHIFT // No, loop - iny // Advance text index - bne NEXTHEX // Always taken + ldx #4 // Shift count + HEXSHIFT: + asl // Hex digit left, MSB to carry + rol MemMap.SHELL.L // Rotate into LSD + rol MemMap.SHELL.H // Rotate into MSD's + dex // Done 4 shifts? + bne HEXSHIFT // No, loop + iny // Advance text index + bne NEXTHEX // Always taken - NOTHEX: cpy MemMap.SHELL.YSAV //Was at least 1 hex digit given? - bne !+ // No! Ignore all, start from scratch - rts -!: - bit MemMap.SHELL.MODE //Test MODE byte - bvc NOTSTOR // B6=0 is STOR, 1 is XAM or BLOCK XAM + NOTHEX: cpy MemMap.SHELL.YSAV //Was at least 1 hex digit given? + bne !+ // No! Ignore all, start from scratch + rts + !: + bit MemMap.SHELL.MODE //Test MODE byte + bvc NOTSTOR // B6=0 is STOR, 1 is XAM or BLOCK XAM // STOR mode, save LSD of new hex byte - lda MemMap.SHELL.L // LSD's of hex data - sta (MemMap.SHELL.STL,X) //Store current 'store index'(X=0) - inc MemMap.SHELL.STL //Increment store index. - bne NEXTITEM // No carry! - inc MemMap.SHELL.STH // Add carry to 'store index' high -TONEXTITEM: jmp NEXTITEM //Get next command item. + lda MemMap.SHELL.L // LSD's of hex data + sta (MemMap.SHELL.STL,X) //Store current 'store index'(X=0) + inc MemMap.SHELL.STL //Increment store index. + bne NEXTITEM // No carry! + inc MemMap.SHELL.STH // Add carry to 'store index' high + TONEXTITEM: + jmp NEXTITEM //Get next command item. //------------------------------------------------------------------------- // 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 //------------------------------------------------------------------------- -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 - ldx #2 // Copy 2 bytes -SETADR: lda MemMap.SHELL.L-1,X // Copy hex data to - sta MemMap.SHELL.STL-1,X // 'store index' - sta MemMap.SHELL.XAML-1,X // and to 'XAM index' - dex // Next of 2 bytes - bne SETADR // Loop unless X = 0 + ldx #2 // Copy 2 bytes + SETADR: lda MemMap.SHELL.L-1,X // Copy hex data to + sta MemMap.SHELL.STL-1,X // 'store index' + sta MemMap.SHELL.XAML-1,X // and to 'XAM index' + dex // Next of 2 bytes + bne SETADR // Loop unless X = 0 // Print address and data from this address, fall through next BNE. -NXTPRNT: bne PRDATA // NE means no address to print - lda #CR // Print CR first - PrintChar() - lda MemMap.SHELL.XAMH // Output high-order byte of address - jsr PRBYTE - lda MemMap.SHELL.XAML // Output low-order byte of address - jsr PRBYTE - lda #':' // Print colon - PrintChar() + NXTPRNT: + bne PRDATA // NE means no address to print + lda #CR // Print CR first + PrintChar() + lda MemMap.SHELL.XAMH // Output high-order byte of address + jsr PRBYTE + lda MemMap.SHELL.XAML // Output low-order byte of address + jsr PRBYTE + lda #':' // Print colon + PrintChar() -PRDATA: lda #' ' // Print space - PrintChar() - lda (MemMap.SHELL.XAML,X) // Get data from address (X=0) - jsr PRBYTE // Output it in hex format -XAMNEXT: stx MemMap.SHELL.MODE // 0 -> MODE (XAM mode). - lda MemMap.SHELL.XAML // See if there's more to print - cmp MemMap.SHELL.L - lda MemMap.SHELL.XAMH - sbc MemMap.SHELL.H - bcs TONEXTITEM // Not less! No more data to output + PRDATA: lda #' ' // Print space + PrintChar() + lda (MemMap.SHELL.XAML,X) // Get data from address (X=0) + jsr PRBYTE // Output it in hex format + XAMNEXT: + stx MemMap.SHELL.MODE // 0 -> MODE (XAM mode). + lda MemMap.SHELL.XAML // See if there's more to print + cmp MemMap.SHELL.L + lda MemMap.SHELL.XAMH + sbc MemMap.SHELL.H + bcs TONEXTITEM // Not less! No more data to output - inc MemMap.SHELL.XAML // Increment 'examine index' - bne MOD8CHK // No carry! - inc MemMap.SHELL.XAMH + inc MemMap.SHELL.XAML // Increment 'examine index' + bne MOD8CHK // No carry! + inc MemMap.SHELL.XAMH -MOD8CHK: lda MemMap.SHELL.XAML // If address MOD 8 = 0 start new line - and #%00000111 - bpl NXTPRNT // Always taken. + MOD8CHK: + lda MemMap.SHELL.XAML // If address MOD 8 = 0 start new line + and #%00000111 + bpl NXTPRNT // Always taken. // ------------------------------------------------------------------------- // Subroutine to print a byte in A in hex form (destructive) // ------------------------------------------------------------------------- -PRBYTE: pha // Save A for LSD - lsr - lsr - lsr // MSD to LSD position - lsr - jsr PRHEX // Output hex digit - pla // Restore A + PRBYTE: + pha // Save A for LSD + lsr + lsr + lsr // MSD to LSD position + lsr + jsr PRHEX // Output hex digit + pla // Restore A // Fall through to print hex routine @@ -246,14 +249,14 @@ PRBYTE: pha // Save A for LSD // Subroutine to print a hexadecimal digit // ------------------------------------------------------------------------- -PRHEX: and #%00001111 // Mask LSD for hex print - ora #'0' // Add "0" - cmp #'9'+1 // Is it a decimal digit? - bcc !+ // Yes! output it - adc #6 // Add offset for letter A-F - !: - PrintChar() - rts + PRHEX: and #%00001111 // Mask LSD for hex print + ora #'0' // Add "0" + cmp #'9'+1 // Is it a decimal digit? + bcc !+ // Yes! output it + adc #6 // Add offset for letter A-F + !: + PrintChar() + rts } @@ -263,31 +266,31 @@ PRHEX: and #%00001111 // Mask LSD for hex prin // ======================================================== * = * "WozShell Data" -module_type: .byte Module.TYPES.PROG -version: .byte 1, 2, 0 +module_type: .byte Module.TYPES.PROG +version: .byte 1, 2, 0 .encoding "screencode_mixed" module_name: - .text "woz-shell" - .byte 0 + .text "woz-shell" + .byte 0 helpString: - .text "----------------------" - .byte $8e - .text "h : this help" - .byte $8e - .text "r : hard reset" - .byte $8e - .text "v : modue versions" - .byte $8e - .text "----------------------" - .byte $8e, 0 + .text "----------------------" + .byte $8e + .text "h : this help" + .byte $8e + .text "r : hard reset" + .byte $8e + .text "v : modue versions" + .byte $8e + .text "----------------------" + .byte $8e, 0 aboutString: - .text "woz64 mon - v 0.1.5" - .byte $8e, 0 + .text "woz64 mon - v 0.1.5" + .byte $8e, 0 lineString: - .text "----------------------------------------" - .byte $8e, 0 + .text "----------------------------------------" + .byte $8e, 0 #import "../core/mem_map.asm"