Refactoring

This commit is contained in:
stid 2020-01-12 00:10:01 -08:00
parent 145e00f85c
commit faa93e90a8
13 changed files with 758 additions and 362 deletions

View File

@ -1,4 +1,44 @@
# Compile to Cart
# VSCODE
``` json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build -> C64 -> VICE",
"type": "shell",
"osx": {
"command": "java -jar /opt/develop/stid/c64/KickAssembler/KickAss.jar -odir bin -log /opt/develop/stid/c64/woz64/bin/buildlog.txt -showmem /opt/develop/stid/c64/woz64/main.asm && /usr/local/bin/x64 bin/main.prg 2> /dev/null"
},
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true
},
"problemMatcher": {
"owner": "acme",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^(Error - File\\s+(.*), line (\\d+) (\\(Zone .*\\))?:\\s+(.*))$",
"file": 2,
"location": 3,
"message": 1
}
}
}
]
}
```
# Compile to Cart (Vice)
``` bash
cartconv -t normal -name "woz" -i main.prg -o woz.crt

57
core/init.asm Normal file
View File

@ -0,0 +1,57 @@
#importonce
#import "../libs/memory.asm"
#import "../libs/math.asm"
#import "../libs/print.asm"
#import "../core/keyboard.asm"
#import "../core/screen.asm"
#import "../progs/woz_shell.asm"
.filenamespace Init
* = * "Init Core"
// ------------------------------------
// METHODS
// ------------------------------------
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
}
toDebug: {
// Debug All Modules
ModuleDefaultToDebug(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"
version: .byte 1, 0, 0
module_name:
.text "core:init"
.byte 0
#import "../core/mem_map.asm"

View File

@ -1,40 +1,60 @@
// Advanced Version of Keyb Input routine
#importonce
.filenamespace Keyboard2
#import "memory.asm"
#import "../libs/module.asm"
// ------------------------------------
// MACROS
// ------------------------------------
.filenamespace Keyboard
#import "../libs/memory.asm"
* = * "Keyboard Module"
// ------------------------------------
// CONSTANTS
// ------------------------------------
.const CIA1_KeybWrite = $DC00
.const CIA1_KeybRead = $DC01
.const cSYS_DelayValue = 32
.const cKeybW_Row1 = $FE
//------------------------------------------------------------------------------------
// ------------------------------------
// METHODS
// ------------------------------------
init: {
lda #64
sta MemMap.KEYB2.SYS_Lstx
sta MemMap.KEYB2.SYS_Sfdx
sta MemMap.KEYBOARD.SYS_Lstx
sta MemMap.KEYBOARD.SYS_Sfdx
lda #cSYS_DelayValue
sta MemMap.KEYB2.SYS_Delay
sta MemMap.KEYBOARD.SYS_Delay
lda #6
sta MemMap.KEYB2.SYS_Kount
sta MemMap.KEYBOARD.SYS_Kount
lda #0
sta MemMap.KEYB2.SYS_Shflag
sta MemMap.KEYB2.SYS_Lstshf
sta MemMap.KEYBOARD.SYS_Shflag
sta MemMap.KEYBOARD.SYS_Lstshf
sta MemMap.KEYB2.SYS_Ndx
sta MemMap.KEYBOARD.SYS_Ndx
lda #10
sta MemMap.KEYB2.SYS_Xmax
sta MemMap.KEYBOARD.SYS_Xmax
// CLODE TO RAM
clone(cloneStart, cloneEnd, $1000)
MemoryClone(cloneStart, cloneEnd, $1000)
rts
}
toDebug: {
ModuleDefaultToDebug(module_name, version)
rts
}
KeyMapVec:
.word KeyMap1, KeyMap2, KeyMap3, KeyMap4
@ -86,7 +106,12 @@ KeyMap4:
.byte $90, $06, $FF, $05, $FF, $FF, $11, $FF
.byte $FF
* = * "Keyb Start"
// ------------------------------------
// RAM METHODS
// ------------------------------------
* = * "Keyboard Ram"
cloneStart:
@ -100,10 +125,10 @@ ReadKeyb:
// Clear Shift Flag
lda #$40
sta MemMap.KEYB2.SYS_Sfdx
sta MemMap.KEYBOARD.SYS_Sfdx
lda #0
sta MemMap.KEYB2.SYS_Shflag
sta MemMap.KEYBOARD.SYS_Shflag
sta CIA1_KeybWrite
ldx CIA1_KeybRead
@ -113,7 +138,7 @@ ReadKeyb:
ldy #$00
lda #7
sta MemMap.KEYB2.KeyR
sta MemMap.KEYBOARD.KeyR
lda #cKeybW_Row1
sta @SMC_Row + 1
@ -141,11 +166,11 @@ ReadKeyb:
beq @NotShift // Stop Key
// Accumulate shift key types (SHIFT=1, COMM=2, CTRL=4)
ora MemMap.KEYB2.SYS_Shflag
sta MemMap.KEYB2.SYS_Shflag
ora MemMap.KEYBOARD.SYS_Shflag
sta MemMap.KEYBOARD.SYS_Shflag
bpl @SMC_A
@NotShift: sty MemMap.KEYB2.SYS_Sfdx
@NotShift: sty MemMap.KEYBOARD.SYS_Sfdx
@SMC_A: lda #0
@ -155,63 +180,63 @@ ReadKeyb:
sec
rol @SMC_Row + 1
dec MemMap.KEYB2.KeyR
dec MemMap.KEYBOARD.KeyR
bpl @SMC_Row
jmp @ProcKeyImg
// Handles the key repeat
@Process: ldy MemMap.KEYB2.SYS_Sfdx
@Process: ldy MemMap.KEYBOARD.SYS_Sfdx
@SMC_Key: lda $FFFF,Y
tax
cpy MemMap.KEYB2.SYS_Lstx
cpy MemMap.KEYBOARD.SYS_Lstx
beq @SameKey
ldy #cSYS_DelayValue
sty MemMap.KEYB2.SYS_Delay // Repeat delay counter
sty MemMap.KEYBOARD.SYS_Delay // Repeat delay counter
bne @Cleanup
@SameKey: and #$7F
ldy MemMap.KEYB2.SYS_Delay
ldy MemMap.KEYBOARD.SYS_Delay
beq @EndDelay
dec MemMap.KEYB2.SYS_Delay
dec MemMap.KEYBOARD.SYS_Delay
bne @Exit
@EndDelay: dec MemMap.KEYB2.SYS_Kount
@EndDelay: dec MemMap.KEYBOARD.SYS_Kount
bne @Exit
ldy #$04
sty MemMap.KEYB2.SYS_Kount
ldy MemMap.KEYB2.SYS_Ndx
sty MemMap.KEYBOARD.SYS_Kount
ldy MemMap.KEYBOARD.SYS_Ndx
dey
bpl @Exit
// Updates the previous key and shift storage
@Cleanup: ldy MemMap.KEYB2.SYS_Sfdx
sty MemMap.KEYB2.SYS_Lstx
ldy MemMap.KEYB2.SYS_Shflag
sty MemMap.KEYB2.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
txa
ldx MemMap.KEYB2.SYS_Ndx
cpx MemMap.KEYB2.SYS_Xmax
ldx MemMap.KEYBOARD.SYS_Ndx
cpx MemMap.KEYBOARD.SYS_Xmax
bcs @Exit
sta MemMap.KEYB2.SYS_Keyd,X
sta MemMap.KEYBOARD.SYS_Keyd,X
inx
stx MemMap.KEYB2.SYS_Ndx
stx MemMap.KEYBOARD.SYS_Ndx
@Exit: lda #$7F
sta CIA1_KeybWrite
rts
@ProcKeyImg:
lda MemMap.KEYB2.SYS_Shflag
lda MemMap.KEYBOARD.SYS_Shflag
cmp #$03 // C= + SHIFT
bne @SetDecodeTable
cmp MemMap.KEYB2.SYS_Lstshf
cmp MemMap.KEYBOARD.SYS_Lstshf
beq @Exit
@SetDecodeTable:
@ -227,31 +252,38 @@ ReadKeyb:
jmp @Process
//------------------------------------------------------------------------------------
GetKey: lda MemMap.KEYB2.SYS_Ndx
GetKey: lda MemMap.KEYBOARD.SYS_Ndx
bne @IsKey
@NoKey: lda #255 // Null
sec
rts
@IsKey: ldy MemMap.KEYB2.SYS_Keyd
@IsKey: ldy MemMap.KEYBOARD.SYS_Keyd
ldx #0
@Loop: lda MemMap.KEYB2.SYS_Keyd + 1,X
sta MemMap.KEYB2.SYS_Keyd,X
@Loop: lda MemMap.KEYBOARD.SYS_Keyd + 1,X
sta MemMap.KEYBOARD.SYS_Keyd,X
inx
cpx MemMap.KEYB2.SYS_Ndx
cpx MemMap.KEYBOARD.SYS_Ndx
bne @Loop
dec MemMap.KEYB2.SYS_Ndx
dec MemMap.KEYBOARD.SYS_Ndx
tya
clc
rts
}
* = * "Keyb: cloneEnd"
* = * "Keyboard Ram End"
cloneEnd:
// ------------------------------------
// DATA
// ------------------------------------
* = * "Keyboard Module Data"
version: .byte 1, 1, 0
module_name:
.text "core:keyboard"
.byte 0
#import "../core/mem_map.asm"
#import "mem_map.asm"

View File

@ -21,7 +21,7 @@
result: .word 0
}
.namespace KEYB2 {
.namespace KEYBOARD {
KeyR: .byte 0
SYS_Keyd: .fill $10,0
SYS_Ndx: .byte 0
@ -40,6 +40,11 @@
size: .word 0
}
.namespace MODULE {
versionPtr: .word 0
}
.namespace SHELL {
pos: .byte 0
MODE: .byte 0
@ -53,3 +58,4 @@
.label buffer = $3000 // 256 bytes
}

View File

@ -1,26 +1,15 @@
#importonce
#import "math.asm"
#import "memory.asm"
#import "../libs/math.asm"
#import "../libs/memory.asm"
#import "../libs/module.asm"
// ------------------------------------
// MACROS
// ------------------------------------
* = * "Screen Module"
// -----------------------
// MACROS
// -----------------------
* = * "Screen Routines"
.macro print(stringAddr) {
lda #<stringAddr // Low byte
ldx #>stringAddr // High byte
jsr Screen.print
}
.macro cPrint() {
jsr Screen.printPetChar
}
.macro ClearChunks(baseAddress, clearByte) {
.macro ScreenClearChunks(baseAddress, clearByte) {
lda #clearByte
ldx #0
!loop:
@ -33,41 +22,41 @@
}
.macro ClearScreen(clearByte) {
ClearChunks(Screen.VIDEO_ADDR, clearByte)
.macro ScreenClear(clearByte) {
ScreenClearChunks(Screen.VIDEO_ADDR, clearByte)
}
.macro ClearColorRam(clearByte) {
ClearChunks(Screen.COLOR_ADDR, clearByte)
.macro ScreenClearColorRam(clearByte) {
ScreenClearChunks(Screen.COLOR_ADDR, clearByte)
}
.macro SetBorderColor(color) {
.macro ScreenSetBorderColor(color) {
lda #color
sta $d020
}
.macro SetBackgroundColor(color) {
.macro ScreenSetBackgroundColor(color) {
lda #color
sta $d021
}
.macro SetMultiColor1(color) {
.macro ScreenSetMultiColor1(color) {
lda #color
sta $d022
}
.macro SetMultiColor2(color) {
.macro ScreenSetMultiColor2(color) {
lda #color
sta $d023
}
.macro SetMultiColorMode() {
.macro ScreenSetMultiColorMode() {
lda $d016
ora #16
sta $d016
}
.macro SetScrollMode() {
.macro ScreenSetScrollMode() {
lda $D016
eor #%00001000
sta $D016
@ -76,9 +65,9 @@
.filenamespace Screen
//------------------------------------------------------------------------------------
// CONSTANTS
//------------------------------------------------------------------------------------
// ------------------------------------
// COSTANTS
// ------------------------------------
.label VIDEO_ADDR = $0400
.label COLOR_ADDR = $D800
.label COLUMN_NUM = 40
@ -87,7 +76,9 @@
.label BS = $95
// ------------------------------------
// METHODS
// ------------------------------------
//------------------------------------------------------------------------------------
init: {
@ -97,10 +88,15 @@ init: {
rts
}
toDebug: {
ModuleDefaultToDebug(module_name, version)
rts
}
//------------------------------------------------------------------------------------
scrollUp: {
pha
clone(VIDEO_ADDR+40, VIDEO_ADDR+(COLUMN_NUM*(ROWS_NUM)), VIDEO_ADDR)
MemoryClone(VIDEO_ADDR+40, VIDEO_ADDR+(COLUMN_NUM*(ROWS_NUM)), VIDEO_ADDR)
// clear last line
lda #32
@ -114,21 +110,9 @@ scrollUp: {
rts
}
//------------------------------------------------------------------------------------
printPetChar: {
pha
stx MemMap.SCREEN.PrintPetCharX
sty MemMap.SCREEN.PrintPetCharY
jsr Screen.petToScreen
jsr Screen.printChar
ldy MemMap.SCREEN.PrintPetCharY
ldx MemMap.SCREEN.PrintPetCharX
pla
rts
}
//------------------------------------------------------------------------------------
printChar: {
sendChar: {
sei
stx MemMap.SCREEN.tempX
cmp #CR
@ -188,14 +172,13 @@ printChar: {
dec MemMap.SCREEN.TempVideoPointer+1
!:
//------------------------------------------------------------------------------------
noScrollTriggered:
noEndOfLine:
noScrollTriggered:
noEndOfLine:
pla
// This is a backspace
cmp #BS
bne !+
bne !+
lda #' '
sta (MemMap.SCREEN.TempVideoPointer), y
jmp exit
@ -213,32 +196,6 @@ noEndOfLine:
rts
}
//
// print
//
//
// preparatory ops: .a: low byte string address
// .x: high byte string address
//
// returned values: none
//
print: {
ldy #$00
sta MemMap.SCREEN.TempStringPointer
stx MemMap.SCREEN.TempStringPointer+1
printLoop:
lda (MemMap.SCREEN.TempStringPointer), y
cmp #0
beq exit
jsr Screen.printChar
jmp printLoop
exit:
rts
}
//------------------------------------------------------------------------------------
screenNewLine: {
pha
@ -261,67 +218,10 @@ screenNewLine: {
}
//
// petToScreen
//
//
// preparatory ops: .a: pet byte to convert
//
// returned values: .a: conv SCREEN char
//
petToScreen: {
// $00-$1F
cmp #$1f
bcs !+
sec
adc #128
jmp convDone
// $20-$3F
!:
cmp #$3f
bcs !+
jmp convDone
// $40-$5F
!:
cmp #$5f
bcs !+
sec
sbc #$40
jmp convDone
// $60-$7F
!:
cmp #$7F
bcs !+
sec
sbc #32
jmp convDone
// $80-$9F
!:
cmp #$9F
bcs !+
sec
adc #64
jmp convDone
// $A0-$BF
!:
cmp #$BF
bcs !+
sec
sbc #64
jmp convDone
// $C0-$DF
// $E0-$FE
!:
cmp #$FE
bcs !+
sec
sbc #128
jmp convDone
// $FF
!:
lda $5E
convDone:
rts
}
* = * "Screen Module Data"
version: .byte 1, 0, 0
module_name:
.text "core:screen"
.byte 0
#import "mem_map.asm"
#import "../core/mem_map.asm"

39
hex.asm
View File

@ -1,39 +0,0 @@
#importonce
.filenamespace Hex
* = * "Hex Routines"
//
// btohex
//
//
// preparatory ops: .a: byte to convert
//
// returned values: .a: msn ascii char
// .x: lsn ascii char
// .y: entry value
//
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
#import "mem_map.asm"

View File

@ -1,9 +1,28 @@
#importonce
#import "../libs/module.asm"
// ------------------------------------
// MACROS
// ------------------------------------
.filenamespace Math
* = * "Math Lin"
* = * "Math Routines"
// ------------------------------------
// METHODS
// ------------------------------------
init: {
rts
}
toDebug: {
ModuleDefaultToDebug(module_name, version)
rts
}
//------------------------------------------------------------------------------------
multiply: {
@ -34,4 +53,18 @@ multiply: {
rts
}
#import "mem_map.asm"
// ------------------------------------
// DATA
// ------------------------------------
* = * "Math Lib Data"
version: .byte 1, 1, 0
.encoding "screencode_mixed"
module_name:
.text "lib:math"
.byte 0
#import "../core/mem_map.asm"

156
libs/memory.asm Normal file
View File

@ -0,0 +1,156 @@
#importonce
#import "../libs/module.asm"
* = * "Memory Lib"
// ------------------------------------
// MACROS
// ------------------------------------
.macro MemoryClone(from, to, dest) {
lda #<from
sta MemMap.MEMORY.from
lda #>from
sta MemMap.MEMORY.from+1
lda #<dest
sta MemMap.MEMORY.dest
lda #>dest
sta MemMap.MEMORY.dest+1
lda #<to-from
sta MemMap.MEMORY.size+1
lda #>to-from
sta MemMap.MEMORY.size
jsr Memory.clone
}
.macro MemoryFill(from, to, fillByte) {
lda #<from
sta MemMap.MEMORY.from
lda #>from
sta MemMap.MEMORY.from+1
lda #<to-from
sta MemMap.MEMORY.size+1
lda #>to-from
sta MemMap.MEMORY.size
lda #fillByte
jsr Memory.fill
}
.macro MemoryClear(from, to) {
lda #<from
sta MemMap.MEMORY.from
lda #>from
sta MemMap.MEMORY.from+1
lda #<to-from
sta MemMap.MEMORY.size+1
lda #>to-from
sta MemMap.MEMORY.size
jsr Memory.clear
}
// ------------------------------------
// METHODS
// ------------------------------------
.filenamespace Memory
init: {
rts
}
toDebug: {
ModuleDefaultToDebug(module_name, version)
rts
}
// Clone Memopry Range
//
// MemMap.MEMORY.from - Should contain the target pointer
// MemMap.MEMORY.dest - Should contain the destination pointer
// MemMap.MEMORY.size - Should contain the size to copy
clone: {
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: rts
}
// Fill Memopry Range with byte loaded in A
//
// MemMap.MEMORY.dest - Should contain the destination pointer
// MemMap.MEMORY.size - Should contain the size to copy
// A - The byte to fill memory with
fill: {
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: rts
}
// Clear Memory with 0
//
// MemMap.MEMORY.dest - Should contain the destination pointer
// MemMap.MEMORY.size - Should contain the size to copy
clear: {
lda #00
jmp Memory.fill
}
// ------------------------------------
// DATA
// ------------------------------------
* = * "Memory Lib Data"
version: .byte 1, 1, 0
.encoding "screencode_mixed"
module_name:
.text "lib:memory"
.byte 0
#import "../core/mem_map.asm"
#import "../core/screen.asm"

74
libs/module.asm Normal file
View File

@ -0,0 +1,74 @@
#importonce
#import "print.asm"
// ------------------------------------
// MACROS
// ------------------------------------
.macro ModulePrintVersion(stringAddr) {
lda #<stringAddr // Low byte
ldx #>stringAddr // High byte
jsr Module.printVersion
}
.macro ModuleDefaultToDebug(module_name, version) {
PrintLine(module_name)
ModulePrintVersion(version)
PrintNewLine()
}
.filenamespace Module
* = * "Module Lb"
// ------------------------------------
// METHODS
// ------------------------------------
init: {
rts
}
toDebug: {
ModuleDefaultToDebug(module_name, version)
rts
}
//------------------------------------------------------------------------------------
printVersion: {
.break
sta MemMap.MODULE.versionPtr
stx MemMap.MODULE.versionPtr+1
ldy #0
jsr printNext
lda #'.'
PrintChar()
jsr printNext
lda #'.'
PrintChar()
jsr printNext
rts
printNext:
lda (MemMap.MODULE.versionPtr), y
clc
adc #$30
PrintChar()
iny
rts
}
// ------------------------------------
// DATA
// ------------------------------------
* = * "Module Lib Data"
version: .byte 1, 0, 0
.encoding "screencode_mixed"
module_name:
.text "lib:module"
.byte 0
#import "../core/mem_map.asm"

190
libs/print.asm Normal file
View File

@ -0,0 +1,190 @@
#importonce
#import "math.asm"
#import "../core/screen.asm"
#import "../libs/module.asm"
* = * "Print Lib"
// ------------------------------------
// MACROS
// ------------------------------------
.macro PrintLine(stringAddr) {
lda #<stringAddr // Low byte
ldx #>stringAddr // High byte
jsr Print.printLine
}
.macro PrintChar() {
jsr Print.printPetChar
}
.macro PrintNewLine() {
jsr Screen.screenNewLine
}
.filenamespace Print
// ------------------------------------
// METHODS
// ------------------------------------
//------------------------------------------------------------------------------------
init: {
rts
}
//------------------------------------------------------------------------------------
toDebug: {
ModuleDefaultToDebug(module_name, version)
rts
}
//------------------------------------------------------------------------------------
printPetChar: {
pha
stx MemMap.SCREEN.PrintPetCharX
sty MemMap.SCREEN.PrintPetCharY
jsr Print.petCharToScreenChar
jsr Screen.sendChar
ldy MemMap.SCREEN.PrintPetCharY
ldx MemMap.SCREEN.PrintPetCharX
pla
rts
}
//
// printLine
//
//
// preparatory ops: .a: low byte string address
// .x: high byte string address
//
// returned values: none
//
printLine: {
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
exit:
rts
}
//
// btohex
//
//
// preparatory ops: .a: byte to convert
//
// returned values: .a: msn ascii char
// .x: lsn ascii char
// .y: entry value
//
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
}
//
// petToScreen
//
//
// preparatory ops: .a: pet byte to convert
//
// returned values: .a: conv SCREEN char
//
petCharToScreenChar: {
// $00-$1F
cmp #$1f
bcs !+
sec
adc #128
jmp convDone
// $20-$3F
!:
cmp #$3f
bcs !+
jmp convDone
// $40-$5F
!:
cmp #$5f
bcs !+
sec
sbc #$40
jmp convDone
// $60-$7F
!:
cmp #$7F
bcs !+
sec
sbc #32
jmp convDone
// $80-$9F
!:
cmp #$9F
bcs !+
sec
adc #64
jmp convDone
// $A0-$BF
!:
cmp #$BF
bcs !+
sec
sbc #64
jmp convDone
// $C0-$DF
// $E0-$FE
!:
cmp #$FE
bcs !+
sec
sbc #128
jmp convDone
// $FF
!:
lda $5E
convDone:
rts
}
// ------------------------------------
// DATA
// ------------------------------------
* = * "Print Lib Data"
version: .byte 1, 0, 0
.encoding "screencode_mixed"
module_name:
.text "lib:print"
.byte 0
#import "../core/mem_map.asm"

View File

@ -1,5 +1,5 @@
BasicUpstart2(start)
#import "mem_map.asm"
#import "./core/mem_map.asm"
* = $8000 "Main"
@ -25,9 +25,11 @@ BasicUpstart2(start)
.byte $C3,$C2,$CD,'8','0' //..CBM80..
//------------------------------------------------------------------------------------
#import "screen.asm"
#import "keyb2.asm"
#import "shell.asm"
#import "./core/init.asm"
#import "./libs/print.asm"
#import "./core/screen.asm"
#import "./core/keyboard.asm"
#import "./progs/woz_shell.asm"
//------------------------------------------------------------------------------------
// Main Program
@ -51,40 +53,36 @@ coldstart:
//------------------------------------------------------------------------------------
start:
jsr initApp;
print(lineString)
print(testString)
print(lineString)
jsr WozShell.start
loop:
lda #$FF
Raster: cmp RASTER_LINE // Raster done?
bne Raster
jsr Keyboard2.ReadKeyb
jsr Keyboard2.GetKey
jsr Keyboard.ReadKeyb
jsr Keyboard.GetKey
bcs loop
cmp #CR
beq execute
cmp #BS
beq backspace
inputChar:
jsr Shell.push // Char in Buffer
cPrint()
jsr WozShell.push // Char in Buffer
PrintChar()
jmp loop
backspace:
jsr Shell.backspace
cPrint()
jsr WozShell.backspace
PrintChar()
jmp loop
execute:
jsr Shell.push // CR in Buffer
jsr WozShell.push // CR in Buffer
jsr Screen.screenNewLine
jsr Shell.exec
jsr WozShell.exec
jsr Screen.screenNewLine
jsr Shell.clear
jsr WozShell.clear
jmp loop
//------------------------------------------------------------------------------------
@ -105,44 +103,21 @@ initApp: {
and TIMER_A_CTRL
sta TIMER_A_CTRL
ClearColorRam($00)
ClearScreen(' ')
SetBorderColor(BORDER_COLOR)
SetBackgroundColor(MAIN_COLOR)
jsr Screen.init
jsr Keyboard2.init
jsr Shell.init
ScreenClearColorRam($00)
ScreenClear(' ')
ScreenSetBorderColor(BORDER_COLOR)
ScreenSetBackgroundColor(MAIN_COLOR)
jsr Init.init
cli
rts
}
//------------------------------------------------------------------------------------
* = * "Hoax"
hoax: {
print(hoaxString)
jmp loop
}
//------------------------------------------------------------------------------------
* = * "Kernel Data"
.encoding "screencode_mixed"
version: .byte 00
revision: .byte 01
minor: .byte 05
testString:
.text "woz64 mon - v 0.1.5"
.byte $8e, 0
lineString:
.text "----------------------------------------"
.byte $8e, 0
hoaxString:
.text "=stid= 1972"
.byte $8e, 0
* = $9FFF "EpromFiller"
.byte 0
.byte 0

View File

@ -1,57 +0,0 @@
#importonce
* = * "Memory Routines"
.macro clone(from, to, dest) {
lda #<from
sta MemMap.MEMORY.from
lda #>from
sta MemMap.MEMORY.from+1
lda #<dest
sta MemMap.MEMORY.dest
lda #>dest
sta MemMap.MEMORY.dest+1
lda #<to-from
sta MemMap.MEMORY.size+1
lda #>to-from
sta MemMap.MEMORY.size
jsr Memory._clone
}
.filenamespace Memory
// move memory down
//
// from = source start address
// to = destination start address
// size = number of bytes to move
//
_clone: {
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: rts
}
#import "mem_map.asm"

View File

@ -1,9 +1,11 @@
#importonce
.filenamespace Shell
.filenamespace WozShell
#import "screen.asm"
#import "../libs/print.asm"
#import "../libs/module.asm"
#import "../core/init.asm"
* = * "Shell Routines"
* = * "WozShell Routines"
.const CR = $0d
.const R = $52
@ -11,11 +13,24 @@
clear:
init: {
lda #-1
sta MemMap.SHELL.pos
rts
}
start: {
PrintLine(lineString)
PrintLine(aboutString)
PrintLine(lineString)
rts
}
toDebug: {
ModuleDefaultToDebug(module_name, version)
rts
}
push: {
ldy MemMap.SHELL.pos
iny
@ -38,7 +53,6 @@ backspace: {
}
exec: {
.break
lda MemMap.SHELL.buffer // Check first char
cmp #'!'
beq stidExec // if ! is stid mon command
@ -48,33 +62,37 @@ exec: {
stidExec: {
.break
ldy #1
lda MemMap.SHELL.buffer, y
cmp #$48
cmp #$48 // H
beq cmdHelp
cmp #$52
cmp #$52 // R
beq cmdReset
cmp #$56 // Z
beq cmdZeroPageInfo
done:
rts
// STID Commands
cmdHelp:
print(helpString)
.break
PrintLine(helpString)
jmp done
cmdReset:
jmp $fce2 // SYS 64738
cmdZeroPageInfo:
jsr Init.toDebug
jmp done
}
// WOZ MONITOR FLOW - FROM APPLE1
wozExec: {
ldy #-1
@ -175,16 +193,16 @@ SETADR: lda MemMap.SHELL.L-1,X // Copy hex data to
NXTPRNT: bne PRDATA // NE means no address to print
lda #CR // Print CR first
cPrint()
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
cPrint()
PrintChar()
PRDATA: lda #' ' // Print space
cPrint()
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).
@ -226,26 +244,37 @@ PRHEX: and #%00001111 // Mask LSD for hex prin
bcc !+ // Yes! output it
adc #6 // Add offset for letter A-F
!:
cPrint()
PrintChar()
rts
}
//------------------------------------------------------------------------------------
* = * "Shell Data"
* = * "WozShell Data"
version: .byte 1, 2, 0
.encoding "screencode_mixed"
module_name:
.text "prg:woz-shell"
.byte 0
helpString:
.text "----------------------"
.byte $8e
.text "h : this help"
.byte $8e
.text "r : hard reset"
.byte $8e
.text "z : zero page params"
.byte $8e
.text "----------------------"
.byte $8e, 0
.text "----------------------"
.byte $8e
.text "h : this help"
.byte $8e
.text "r : hard reset"
.byte $8e
.text "z : zero page params"
.byte $8e
.text "----------------------"
.byte $8e, 0
#import "mem_map.asm"
aboutString:
.text "woz64 mon - v 0.1.5"
.byte $8e, 0
lineString:
.text "----------------------------------------"
.byte $8e, 0
#import "../core/mem_map.asm"