1
0
mirror of https://github.com/stid/woz64.git synced 2024-11-29 12:49:17 +00:00

Woz alpha

This commit is contained in:
stid 2019-11-16 23:41:00 -08:00
parent 6013ca5d87
commit 65687a91fd
7 changed files with 323 additions and 101 deletions

View File

@ -12,39 +12,39 @@
init:
lda #64
sta MemMap.KEYB2_SPACE.SYS_Lstx
sta MemMap.KEYB2_SPACE.SYS_Sfdx
sta MemMap.KEYB2.SYS_Lstx
sta MemMap.KEYB2.SYS_Sfdx
lda #cSYS_DelayValue
sta MemMap.KEYB2_SPACE.SYS_Delay
sta MemMap.KEYB2.SYS_Delay
lda #6
sta MemMap.KEYB2_SPACE.SYS_Kount
sta MemMap.KEYB2.SYS_Kount
lda #0
sta MemMap.KEYB2_SPACE.SYS_Shflag
sta MemMap.KEYB2_SPACE.SYS_Lstshf
sta MemMap.KEYB2.SYS_Shflag
sta MemMap.KEYB2.SYS_Lstshf
sta MemMap.KEYB2_SPACE.SYS_Ndx
sta MemMap.KEYB2.SYS_Ndx
lda #10
sta MemMap.KEYB2_SPACE.SYS_Xmax
sta MemMap.KEYB2.SYS_Xmax
// CLODE TO RAM
lda #<cloneStart
sta MemMap.MEMORY_SPACE.from
sta MemMap.MEMORY.from
lda #>cloneStart
sta MemMap.MEMORY_SPACE.from+1
sta MemMap.MEMORY.from+1
lda #<$1000
sta MemMap.MEMORY_SPACE.to
sta MemMap.MEMORY.to
lda #>$1000
sta MemMap.MEMORY_SPACE.to+1
sta MemMap.MEMORY.to+1
lda #<cloneEnd-ReadKeyb
sta MemMap.MEMORY_SPACE.size+1
sta MemMap.MEMORY.size+1
lda #>cloneEnd-ReadKeyb
sta MemMap.MEMORY_SPACE.size
sta MemMap.MEMORY.size
jsr Memory.clone
@ -114,10 +114,10 @@ ReadKeyb:
// Clear Shift Flag
lda #$40
sta MemMap.KEYB2_SPACE.SYS_Sfdx
sta MemMap.KEYB2.SYS_Sfdx
lda #0
sta MemMap.KEYB2_SPACE.SYS_Shflag
sta MemMap.KEYB2.SYS_Shflag
sta CIA1_KeybWrite
ldx CIA1_KeybRead
@ -127,7 +127,7 @@ ReadKeyb:
ldy #$00
lda #7
sta MemMap.KEYB2_SPACE.KeyR
sta MemMap.KEYB2.KeyR
lda #cKeybW_Row1
sta @SMC_Row + 1
@ -155,11 +155,11 @@ ReadKeyb:
beq @NotShift // Stop Key
// Accumulate shift key types (SHIFT=1, COMM=2, CTRL=4)
ora MemMap.KEYB2_SPACE.SYS_Shflag
sta MemMap.KEYB2_SPACE.SYS_Shflag
ora MemMap.KEYB2.SYS_Shflag
sta MemMap.KEYB2.SYS_Shflag
bpl @SMC_A
@NotShift: sty MemMap.KEYB2_SPACE.SYS_Sfdx
@NotShift: sty MemMap.KEYB2.SYS_Sfdx
@SMC_A: lda #0
@ -169,63 +169,63 @@ ReadKeyb:
sec
rol @SMC_Row + 1
dec MemMap.KEYB2_SPACE.KeyR
dec MemMap.KEYB2.KeyR
bpl @SMC_Row
jmp @ProcKeyImg
// Handles the key repeat
@Process: ldy MemMap.KEYB2_SPACE.SYS_Sfdx
@Process: ldy MemMap.KEYB2.SYS_Sfdx
@SMC_Key: lda $FFFF,Y
tax
cpy MemMap.KEYB2_SPACE.SYS_Lstx
cpy MemMap.KEYB2.SYS_Lstx
beq @SameKey
ldy #cSYS_DelayValue
sty MemMap.KEYB2_SPACE.SYS_Delay // Repeat delay counter
sty MemMap.KEYB2.SYS_Delay // Repeat delay counter
bne @Cleanup
@SameKey: and #$7F
ldy MemMap.KEYB2_SPACE.SYS_Delay
ldy MemMap.KEYB2.SYS_Delay
beq @EndDelay
dec MemMap.KEYB2_SPACE.SYS_Delay
dec MemMap.KEYB2.SYS_Delay
bne @Exit
@EndDelay: dec MemMap.KEYB2_SPACE.SYS_Kount
@EndDelay: dec MemMap.KEYB2.SYS_Kount
bne @Exit
ldy #$04
sty MemMap.KEYB2_SPACE.SYS_Kount
ldy MemMap.KEYB2_SPACE.SYS_Ndx
sty MemMap.KEYB2.SYS_Kount
ldy MemMap.KEYB2.SYS_Ndx
dey
bpl @Exit
// Updates the previous key and shift storage
@Cleanup: ldy MemMap.KEYB2_SPACE.SYS_Sfdx
sty MemMap.KEYB2_SPACE.SYS_Lstx
ldy MemMap.KEYB2_SPACE.SYS_Shflag
sty MemMap.KEYB2_SPACE.SYS_Lstshf
@Cleanup: ldy MemMap.KEYB2.SYS_Sfdx
sty MemMap.KEYB2.SYS_Lstx
ldy MemMap.KEYB2.SYS_Shflag
sty MemMap.KEYB2.SYS_Lstshf
cpx #$FF
beq @Exit
txa
ldx MemMap.KEYB2_SPACE.SYS_Ndx
cpx MemMap.KEYB2_SPACE.SYS_Xmax
ldx MemMap.KEYB2.SYS_Ndx
cpx MemMap.KEYB2.SYS_Xmax
bcs @Exit
sta MemMap.KEYB2_SPACE.SYS_Keyd,X
sta MemMap.KEYB2.SYS_Keyd,X
inx
stx MemMap.KEYB2_SPACE.SYS_Ndx
stx MemMap.KEYB2.SYS_Ndx
@Exit: lda #$7F
sta CIA1_KeybWrite
rts
@ProcKeyImg:
lda MemMap.KEYB2_SPACE.SYS_Shflag
lda MemMap.KEYB2.SYS_Shflag
cmp #$03 // C= + SHIFT
bne @SetDecodeTable
cmp MemMap.KEYB2_SPACE.SYS_Lstshf
cmp MemMap.KEYB2.SYS_Lstshf
beq @Exit
@SetDecodeTable:
@ -241,21 +241,21 @@ ReadKeyb:
jmp @Process
// --------------------------
GetKey: lda MemMap.KEYB2_SPACE.SYS_Ndx
GetKey: lda MemMap.KEYB2.SYS_Ndx
bne @IsKey
@NoKey: lda #255 // Null
sec
rts
@IsKey: ldy MemMap.KEYB2_SPACE.SYS_Keyd
@IsKey: ldy MemMap.KEYB2.SYS_Keyd
ldx #0
@Loop: lda MemMap.KEYB2_SPACE.SYS_Keyd + 1,X
sta MemMap.KEYB2_SPACE.SYS_Keyd,X
@Loop: lda MemMap.KEYB2.SYS_Keyd + 1,X
sta MemMap.KEYB2.SYS_Keyd,X
inx
cpx MemMap.KEYB2_SPACE.SYS_Ndx
cpx MemMap.KEYB2.SYS_Ndx
bne @Loop
dec MemMap.KEYB2_SPACE.SYS_Ndx
dec MemMap.KEYB2.SYS_Ndx
tya
clc
rts

View File

@ -17,6 +17,7 @@ BasicUpstart2(start)
#import "screen.asm"
#import "keyb2.asm"
#import "hex.asm"
#import "shell.asm"
* = * "Kernel Start"
@ -43,14 +44,20 @@ Raster: cmp $D012
jsr Keyboard2.ReadKeyb
jsr Keyboard2.GetKey
bcs Skip
cmp #$0d
bne inputChar
.break
// Execute Item
jsr Shell.push
jsr Shell.wozExec
lda #$0d
jsr Screen.petToScreen
cPrint()
jsr Shell.clear
jmp loop
inputChar:
jsr Shell.push
jsr Screen.petToScreen
//jsr Hex.byteToHex
//cPrint()
//txa
cPrint()
@ -65,6 +72,7 @@ initApp: {
SetBackgroundColor(constants.BORDER_COLOR)
jsr Screen.init
jsr Keyboard2.init
jsr Shell.init
rts
}

View File

@ -6,25 +6,25 @@
* = * "Math Routines"
multiply: {
stx MemMap.MATH_SPACE.multiTmpX
stx MemMap.MATH.multiTmpX
pha
lda #$00
ldx #$08
clc
m0: bcc.r m1
clc
adc MemMap.MATH_SPACE.factor2
adc MemMap.MATH.factor2
m1: ror
ror MemMap.MATH_SPACE.factor1
ror MemMap.MATH.factor1
dex
bpl.r m0
ldx MemMap.MATH_SPACE.factor1
ldx MemMap.MATH.factor1
sta MemMap.MATH_SPACE.result
stx MemMap.MATH_SPACE.result+1
sta MemMap.MATH.result
stx MemMap.MATH.result+1
pla
ldx MemMap.MATH_SPACE.multiTmpX
ldx MemMap.MATH.multiTmpX
rts

View File

@ -4,23 +4,24 @@
.const ZPAGE_BASE = $2
.namespace SCREEN_SPACE {
.namespace SCREEN {
.label TempVideoPointer = ZPAGE_BASE // 2 bytes
.label TempStringPointer = ZPAGE_BASE+2 // 2 bytes
.label CursorCol = ZPAGE_BASE+4 // 1 byte
.label CursorRow = ZPAGE_BASE+5 // 1 byte
.label tempY = ZPAGE_BASE+6 // 1 byte
.label tempX = ZPAGE_BASE+7 // 1 byte
.label cTempY = ZPAGE_BASE+8 // 1 byte
}
.namespace MATH_SPACE {
.label factor1 = ZPAGE_BASE+8 // 1 byte
.label factor2 = ZPAGE_BASE+9 // 1 byte
.label multiTmpX = ZPAGE_BASE+10 // 1 byte
.label result = ZPAGE_BASE+11 // 2 bytes
.namespace MATH {
.label factor1 = ZPAGE_BASE+9 // 1 byte
.label factor2 = ZPAGE_BASE+10 // 1 byte
.label multiTmpX = ZPAGE_BASE+11 // 1 byte
.label result = ZPAGE_BASE+12 // 2 bytes
}
.namespace KEYB2_SPACE {
.namespace KEYB2 {
.label KeyR = ZPAGE_BASE+37 // 1 bytes
.label SYS_Keyd = ZPAGE_BASE+38 // 10 bytes
.label SYS_Ndx = ZPAGE_BASE+48 // 1 bytes
@ -33,8 +34,23 @@
.label SYS_Lstshf = ZPAGE_BASE+55 // 1 bytes
}
.namespace MEMORY_SPACE {
.namespace MEMORY {
.label from = ZPAGE_BASE+56 // 2 bytes
.label to = ZPAGE_BASE+58 // 2 bytes
.label size = ZPAGE_BASE+60 // 2 bytes
}
.namespace SHELL {
.label pos = ZPAGE_BASE+62 // 1 bytes
.label MODE = ZPAGE_BASE+63 // 1 bytes
.label L = ZPAGE_BASE+64 // 1 bytes
.label H = ZPAGE_BASE+65 // 1 bytes
.label YSAV = ZPAGE_BASE+66 // 1 bytes
.label STL = ZPAGE_BASE+67 // 1 bytes
.label STH = ZPAGE_BASE+68 // 1 bytes
.label XAML = ZPAGE_BASE+69 // 1 bytes
.label XAMH = ZPAGE_BASE+70 // 1 bytes
.label buffer = $3000 // 256 bytes
}

View File

@ -13,20 +13,20 @@
//
clone:
ldy #0
ldx MemMap.MEMORY_SPACE.size
ldx MemMap.MEMORY.size
beq md2
md1: lda (MemMap.MEMORY_SPACE.from),y // move a page at a time
sta (MemMap.MEMORY_SPACE.to),y
md1: lda (MemMap.MEMORY.from),y // move a page at a time
sta (MemMap.MEMORY.to),y
iny
bne md1
inc MemMap.MEMORY_SPACE.from+1
inc MemMap.MEMORY_SPACE.to+1
inc MemMap.MEMORY.from+1
inc MemMap.MEMORY.to+1
dex
bne md1
md2: ldx MemMap.MEMORY_SPACE.size+1
md2: ldx MemMap.MEMORY.size+1
beq md4
md3: lda (MemMap.MEMORY_SPACE.from),y // move the remaining bytes
sta (MemMap.MEMORY_SPACE.to),y
md3: lda (MemMap.MEMORY.from),y // move the remaining bytes
sta (MemMap.MEMORY.to),y
iny
dex
bne md3

View File

@ -15,7 +15,9 @@
}
.macro cPrint() {
sty MemMap.SCREEN.cTempY
jsr Screen.printChar
ldy MemMap.SCREEN.cTempY
}
.macro ClearScreen(screen, clearByte) {
@ -94,13 +96,13 @@
init: {
lda #$00
sta MemMap.SCREEN_SPACE.CursorCol
sta MemMap.SCREEN_SPACE.CursorRow
sta MemMap.SCREEN.CursorCol
sta MemMap.SCREEN.CursorRow
rts
}
printChar: {
stx MemMap.SCREEN_SPACE.tempX
stx MemMap.SCREEN.tempX
// New Line
cmp #$8e
bne.r !+
@ -110,47 +112,47 @@ printChar: {
!:
// Store Base Video Address 16 bit
ldx #<constants.VIDEO_ADDR // Low byte
stx MemMap.SCREEN_SPACE.TempVideoPointer
stx MemMap.SCREEN.TempVideoPointer
ldx #>constants.VIDEO_ADDR // High byte
stx MemMap.SCREEN_SPACE.TempVideoPointer+1
stx MemMap.SCREEN.TempVideoPointer+1
// Temp Save Y
sty MemMap.SCREEN_SPACE.tempY
sty MemMap.SCREEN.tempY
// CursorRow * 40
ldy MemMap.SCREEN_SPACE.CursorRow
sty MemMap.MATH_SPACE.factor1
ldy MemMap.SCREEN.CursorRow
sty MemMap.MATH.factor1
ldy #constants.COLUMN_NUM
sty MemMap.MATH_SPACE.factor2
sty MemMap.MATH.factor2
jsr Math.multiply
// Add mul result to TempVideoPointer
clc
pha
lda MemMap.MATH_SPACE.result
adc MemMap.SCREEN_SPACE.TempVideoPointer+1
sta MemMap.SCREEN_SPACE.TempVideoPointer+1
lda MemMap.MATH_SPACE.result+1
adc MemMap.SCREEN_SPACE.TempVideoPointer
sta MemMap.SCREEN_SPACE.TempVideoPointer
lda MemMap.MATH.result
adc MemMap.SCREEN.TempVideoPointer+1
sta MemMap.SCREEN.TempVideoPointer+1
lda MemMap.MATH.result+1
adc MemMap.SCREEN.TempVideoPointer
sta MemMap.SCREEN.TempVideoPointer
pla
// Add column
ldy MemMap.SCREEN_SPACE.CursorCol
sta (MemMap.SCREEN_SPACE.TempVideoPointer), y
ldy MemMap.SCREEN.CursorCol
sta (MemMap.SCREEN.TempVideoPointer), y
ldy MemMap.SCREEN_SPACE.tempY
ldy MemMap.SCREEN.tempY
iny
inc MemMap.SCREEN_SPACE.CursorCol
lda MemMap.SCREEN_SPACE.CursorCol
inc MemMap.SCREEN.CursorCol
lda MemMap.SCREEN.CursorCol
cmp #constants.COLUMN_NUM+1
bcc.r exita
// CursorCol > COLUMN_NUM ? new line
jsr screenNewLine
exita:
ldx MemMap.SCREEN_SPACE.tempX
ldx MemMap.SCREEN.tempX
rts
}
@ -167,10 +169,10 @@ exita:
//
print: {
ldy #$00
sta MemMap.SCREEN_SPACE.TempStringPointer
stx MemMap.SCREEN_SPACE.TempStringPointer+1
sta MemMap.SCREEN.TempStringPointer
stx MemMap.SCREEN.TempStringPointer+1
printLoop:
lda (MemMap.SCREEN_SPACE.TempStringPointer), y
lda (MemMap.SCREEN.TempStringPointer), y
cmp #0
beq exit
jsr Screen.printChar
@ -181,8 +183,8 @@ print: {
screenNewLine: {
lda #0
sta MemMap.SCREEN_SPACE.CursorCol
inc MemMap.SCREEN_SPACE.CursorRow
sta MemMap.SCREEN.CursorCol
inc MemMap.SCREEN.CursorRow
rts
}

196
shell.asm Normal file
View File

@ -0,0 +1,196 @@
#importonce
.filenamespace Shell
#import "mem_map.asm"
#import "screen.asm"
* = * "Shell Routines"
.const CR = $0d
init: {
lda #-1
sta MemMap.SHELL.pos
rts
}
push: {
ldy MemMap.SHELL.pos
iny
cpy #127
beq done
sty MemMap.SHELL.pos
sta MemMap.SHELL.buffer, y
done:
rts
}
clear: {
ldy #-1
sty MemMap.SHELL.pos
rts
}
// WOZ MONITOR FLOW - FROM APPLE1
wozExec: {
ldy #-1
lda #0
tax
SETSTOR:
asl
SETMODE: sta MemMap.SHELL.MODE
BLSKIP: iny
NEXTITEM:
.break
lda MemMap.SHELL.buffer,Y //Get character
cmp #$0d
bne 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!
// TODO: THIS IS NOT WORKING
adc #$08 // 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
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
// 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.
//-------------------------------------------------------------------------
// RUN user's program from last opened location
//-------------------------------------------------------------------------
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
// 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
// Print address and data from this address, fall through next BNE.
NXTPRNT: bne PRDATA // NE means no address to print
lda #$8e // Print CR first
cPrint()
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()
PRDATA: lda #' ' // Print space
cPrint()
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
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
// Fall through to print hex routine
// -------------------------------------------------------------------------
// 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 ECHO // Yes! output it
adc #6 // Add offset for letter A-F
jsr Screen.petToScreen
cPrint()
rts
done:
.break
rts
ECHO:
cPrint()
rts
}