Cleanup & Standardize code

This commit is contained in:
stid 2020-01-12 16:52:10 -08:00
parent 411f75b5aa
commit 222326bb1a
9 changed files with 526 additions and 173 deletions

View File

@ -5,16 +5,22 @@
#import "../libs/print.asm" #import "../libs/print.asm"
#import "../core/keyboard.asm" #import "../core/keyboard.asm"
#import "../core/screen.asm" #import "../core/screen.asm"
#import "../libs/module.asm"
#import "../progs/woz_shell.asm" #import "../progs/woz_shell.asm"
.filenamespace Init .filenamespace Init
* = * "Init Core" * = * "Init Core"
// ------------------------------------
// METHODS
// ------------------------------------
// ========================================================
// ////// METHODS /////////////////////////////////////////
// ========================================================
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
init: { init: {
// Init All Modules // Init All Modules
jsr Memory.init jsr Memory.init
@ -27,9 +33,13 @@ init: {
rts rts
} }
// --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
toDebug: { toDebug: {
// Debug All Modules // Debug All Modules
ModuleDefaultToDebug(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
@ -42,14 +52,19 @@ toDebug: {
// ------------------------------------ // ========================================================
// DATA // ////// DATA ////////////////////////////////////////////
// ------------------------------------ // ========================================================
* = * "Init Core Data" * = * "Init Core Data"
version: .byte 1, 0, 0 module_type: .byte Module.TYPES.CORE
version: .byte 1, 1, 0
.encoding "screencode_mixed"
module_name: module_name:
.text "core:init" .text "init"
.byte 0 .byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"

View File

@ -1,30 +1,33 @@
#importonce #importonce
#import "../libs/module.asm" #import "../libs/module.asm"
#import "../libs/memory.asm" #import "../libs/memory.asm"
#import "../libs/module.asm"
// ------------------------------------
// MACROS
// ------------------------------------
.filenamespace Keyboard .filenamespace Keyboard
* = * "Keyboard Module" // ========================================================
// ------------------------------------ // ////// CONSTANTS ///////////////////////////////////////
// CONSTANTS // ========================================================
// ------------------------------------
.const CIA1_KeybWrite = $DC00 .const CIA1_KeybWrite = $DC00
.const CIA1_KeybRead = $DC01 .const CIA1_KeybRead = $DC01
.const cSYS_DelayValue = 32 .const cSYS_DelayValue = 32
.const cKeybW_Row1 = $FE .const cKeybW_Row1 = $FE
* = * "Keyboard Module"
// ------------------------------------ // ========================================================
// METHODS // ////// METHODS ROM /////////////////////////////////////
// ------------------------------------ // ========================================================
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
init: { init: {
lda #64 lda #64
sta MemMap.KEYBOARD.SYS_Lstx sta MemMap.KEYBOARD.SYS_Lstx
@ -45,16 +48,24 @@ init: {
lda #10 lda #10
sta MemMap.KEYBOARD.SYS_Xmax sta MemMap.KEYBOARD.SYS_Xmax
// CLODE TO RAM // Clone self altering Methods to RAM
MemoryClone(cloneStart, cloneEnd, $1000) MemoryClone(cloneStart, cloneEnd, $1000)
rts rts
} }
// --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
toDebug: { toDebug: {
ModuleDefaultToDebug(module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
// ========================================================
// ////// KEYMAPPING RON //////////////////////////////////
// ========================================================
KeyMapVec: KeyMapVec:
.word KeyMap1, KeyMap2, KeyMap3, KeyMap4 .word KeyMap1, KeyMap2, KeyMap3, KeyMap4
@ -107,15 +118,32 @@ KeyMap4:
.byte $FF .byte $FF
// ------------------------------------ // ========================================================
// RAM METHODS // ////// METHODS RAM /////////////////////////////////////
// ------------------------------------ // ========================================================
* = * "Keyboard Ram" * = * "Keyboard Ram"
cloneStart: cloneStart:
// Code between cloneStart & cloneEnd is cloned in RAM
// at Init time. The logic alter the code itself for
// performance and so can't be executed directly in ROM.
// See .pseudopc $1000 directive below.
//------------------------------------------------------------------------------------
// --------------------------------------------------------
// ReadKeyb -
// Read Keyboard input - if any- should be called in a loop
// getKey should be used after to chek if and what key was
// pressed.
//
// Example:
// loop:
// jsr Keyboard.ReadKeyb
// jsr Keyboard.GetKey
// bcs loop
// // Key here is in A
// --------------------------------------------------------
.pseudopc $1000 { .pseudopc $1000 {
ReadKeyb: ReadKeyb:
lda #<KeyMap1 lda #<KeyMap1
@ -251,7 +279,14 @@ ReadKeyb:
sta @SMC_Key + 2 sta @SMC_Key + 2
jmp @Process jmp @Process
//------------------------------------------------------------------------------------ // --------------------------------------------------------
// GetKey -
// Get latest pressed key - if any. Should be used in
// conjuction with ReadKeyb.
//
// Result:
// A = Pressed key code or 0
// --------------------------------------------------------
GetKey: lda MemMap.KEYBOARD.SYS_Ndx GetKey: lda MemMap.KEYBOARD.SYS_Ndx
bne @IsKey bne @IsKey
@ -276,14 +311,19 @@ GetKey: lda MemMap.KEYBOARD.SYS_Ndx
cloneEnd: cloneEnd:
// ------------------------------------ // ========================================================
// DATA // ////// DATA ////////////////////////////////////////////
// ------------------------------------ // ========================================================
* = * "Keyboard Module Data" * = * "Keyboard Module Data"
version: .byte 1, 1, 0 module_type: .byte Module.TYPES.CORE
version: .byte 1, 1, 0
.encoding "screencode_mixed"
module_name: module_name:
.text "core:keyboard" .text "keyboard"
.byte 0 .byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"

View File

@ -3,12 +3,22 @@
#import "../libs/memory.asm" #import "../libs/memory.asm"
#import "../libs/module.asm" #import "../libs/module.asm"
// ------------------------------------
// MACROS // ========================================================
// ------------------------------------ // ////// MACROS //////////////////////////////////////////
// ========================================================
* = * "Screen Module" * = * "Screen Module"
// --------------------------------------------------------
// ScreenClearChunks -
// Fast clear screen mem chunks.
//
// Parameters:
// baseAddress = Pointer to screen orcolor map Address
// clearByte = Byte to use to clear screen
// --------------------------------------------------------
.macro ScreenClearChunks(baseAddress, clearByte) { .macro ScreenClearChunks(baseAddress, clearByte) {
lda #clearByte lda #clearByte
ldx #0 ldx #0
@ -22,52 +32,95 @@
} }
// --------------------------------------------------------
// ScreenClear -
// Fast clear screen characters mem.
//
// Parameters:
// clearByte = Byte to use to clear screen
// --------------------------------------------------------
.macro ScreenClear(clearByte) { .macro ScreenClear(clearByte) {
ScreenClearChunks(Screen.VIDEO_ADDR, clearByte) ScreenClearChunks(Screen.VIDEO_ADDR, clearByte)
} }
// --------------------------------------------------------
// ScreenClear -
// Fast clear screen Color Ram.
//
// Parameters:
// clearByte = Byte to use to clear screen
// --------------------------------------------------------
.macro ScreenClearColorRam(clearByte) { .macro ScreenClearColorRam(clearByte) {
ScreenClearChunks(Screen.COLOR_ADDR, clearByte) ScreenClearChunks(Screen.COLOR_ADDR, clearByte)
} }
// --------------------------------------------------------
// ScreenSetBorderColor -
// Set Screen border color.
//
// Parameters:
// color = https://www.c64-wiki.com/wiki/Color
// --------------------------------------------------------
.macro ScreenSetBorderColor(color) { .macro ScreenSetBorderColor(color) {
lda #color lda #color
sta $d020 sta $d020
} }
// --------------------------------------------------------
// ScreenSetBackgroundColor -
// Set Screen Backfground color.
//
// Parameters:
// color = https://www.c64-wiki.com/wiki/Color
// --------------------------------------------------------
.macro ScreenSetBackgroundColor(color) { .macro ScreenSetBackgroundColor(color) {
lda #color lda #color
sta $d021 sta $d021
} }
// --------------------------------------------------------
// ScreenSetMultiColor1 -
// Set Screen Muticolor 1.
//
// Parameters:
// color = https://www.c64-wiki.com/wiki/Color
// --------------------------------------------------------
.macro ScreenSetMultiColor1(color) { .macro ScreenSetMultiColor1(color) {
lda #color lda #color
sta $d022 sta $d022
} }
// --------------------------------------------------------
// ScreenSetMultiColor2 -
// Set Screen Muticolor 2.
//
// Parameters:
// color = https://www.c64-wiki.com/wiki/Color
// --------------------------------------------------------
.macro ScreenSetMultiColor2(color) { .macro ScreenSetMultiColor2(color) {
lda #color lda #color
sta $d023 sta $d023
} }
// --------------------------------------------------------
// ScreenSetMultiColorMode -
// Set Screen Muticolor 2.
//
// Parameters:
// color = https://www.c64-wiki.com/wiki/Multicolor_Bitmap_Mode
// --------------------------------------------------------
.macro ScreenSetMultiColorMode() { .macro ScreenSetMultiColorMode() {
lda $d016 lda $d016
ora #16 ora #16
sta $d016 sta $d016
} }
.macro ScreenSetScrollMode() {
lda $D016
eor #%00001000
sta $D016
}
.filenamespace Screen .filenamespace Screen
// ========================================================
// ////// CONSTANTS ///////////////////////////////////////
// ========================================================
// ------------------------------------
// COSTANTS
// ------------------------------------
.label VIDEO_ADDR = $0400 .label VIDEO_ADDR = $0400
.label COLOR_ADDR = $D800 .label COLOR_ADDR = $D800
.label COLUMN_NUM = 40 .label COLUMN_NUM = 40
@ -76,11 +129,15 @@
.label BS = $95 .label BS = $95
// ------------------------------------ // ========================================================
// METHODS // ////// METHODS /////////////////////////////////////////
// ------------------------------------ // ========================================================
//------------------------------------------------------------------------------------
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
init: { init: {
lda #$00 lda #$00
sta MemMap.SCREEN.CursorCol sta MemMap.SCREEN.CursorCol
@ -88,12 +145,19 @@ init: {
rts rts
} }
// --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
toDebug: { toDebug: {
ModuleDefaultToDebug(module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
//------------------------------------------------------------------------------------ // --------------------------------------------------------
// scrollUp -
// Scroll the entire screen UP - 1 line
// --------------------------------------------------------
scrollUp: { scrollUp: {
pha pha
MemoryClone(VIDEO_ADDR+40, VIDEO_ADDR+(COLUMN_NUM*(ROWS_NUM)), VIDEO_ADDR) MemoryClone(VIDEO_ADDR+40, VIDEO_ADDR+(COLUMN_NUM*(ROWS_NUM)), VIDEO_ADDR)
@ -110,7 +174,14 @@ scrollUp: {
} }
//------------------------------------------------------------------------------------ // --------------------------------------------------------
// sendChar -
// Send a single char to the screen. Auto handle line feed,
// end of screen scrolling and Backspace.
//
// Parameters:
// A = Character to Print SCREEN ASCII
// --------------------------------------------------------
sendChar: { sendChar: {
sei sei
stx MemMap.SCREEN.tempX stx MemMap.SCREEN.tempX
@ -195,7 +266,11 @@ sendChar: {
rts rts
} }
//------------------------------------------------------------------------------------ // --------------------------------------------------------
// screenNewLine -
// Insert a New Line to screen - auto handle screen bottom
// linit scroll.
// --------------------------------------------------------
screenNewLine: { screenNewLine: {
pha pha
lda #0 lda #0
@ -216,11 +291,11 @@ screenNewLine: {
rts rts
} }
* = * "Screen Module Data" * = * "Screen Module Data"
version: .byte 1, 0, 0 module_type: .byte Module.TYPES.CORE
version: .byte 1, 0, 0
module_name: module_name:
.text "core:screen" .text "screen"
.byte 0 .byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"

View File

@ -1,30 +1,46 @@
#importonce #importonce
#import "../libs/module.asm" #import "../libs/module.asm"
#import "../libs/module.asm"
// ------------------------------------
// MACROS
// ------------------------------------
.filenamespace Math .filenamespace Math
* = * "Math Lin" * = * "Math Lin"
// ------------------------------------ // ========================================================
// METHODS // ////// METHODS /////////////////////////////////////////
// ------------------------------------ // ========================================================
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
init: { init: {
rts rts
} }
// --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
toDebug: { toDebug: {
ModuleDefaultToDebug(module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
//------------------------------------------------------------------------------------ // --------------------------------------------------------
// multiply -
// 8 Bit in to 16 Bit out Multiplier
//
// Parameters:
// MemMap.MATH.factor1 = 8 Bit Factor 1
// MemMap.MATH.factor2 = 8 Bit Factor 2
//
// Result
// MemMap.MATH.result = 16 bit result
// --------------------------------------------------------
multiply: { multiply: {
sei sei
pha pha
@ -54,15 +70,17 @@ multiply: {
} }
// ------------------------------------ // ========================================================
// DATA // ////// DATA ////////////////////////////////////////////
// ------------------------------------ // ========================================================
* = * "Math Lib Data" * = * "Math Lib Data"
version: .byte 1, 1, 0 module_type: .byte Module.TYPES.LIB
version: .byte 1, 1, 0
.encoding "screencode_mixed" .encoding "screencode_mixed"
module_name: module_name:
.text "lib:math" .text "math"
.byte 0 .byte 0

View File

@ -1,14 +1,22 @@
#importonce #importonce
#import "../libs/module.asm" #import "../libs/module.asm"
#import "../libs/module.asm"
* = * "Memory Lib" // ========================================================
// ////// MACROS //////////////////////////////////////////
// ------------------------------------ // ========================================================
// MACROS
// ------------------------------------
// --------------------------------------------------------
// MemoryClone -
// Clone a range of memory to the passe destination.
//
// Parameters:
// from = Start Memory Pointer to clone
// to = End Memory Pointer to clone
// 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
@ -28,6 +36,15 @@
jsr Memory.clone jsr Memory.clone
} }
// --------------------------------------------------------
// MemoryFill -
// Fill specified memory range with related byte.
//
// Parameters:
// from = Start Memory Pointer to fill
// to = End Memory Pointer to fill
// 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
@ -43,6 +60,14 @@
jsr Memory.fill jsr Memory.fill
} }
// --------------------------------------------------------
// MemoryClear -
// Fill specified memory range with Zero
//
// Parameters:
// from = Start 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
@ -57,27 +82,46 @@
jsr Memory.clear jsr Memory.clear
} }
// ------------------------------------
// METHODS
// ------------------------------------
.filenamespace Memory .filenamespace Memory
* = * "Memory Lib"
// ========================================================
// ////// METHODS /////////////////////////////////////////
// ========================================================
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
init: { init: {
rts rts
} }
// --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
toDebug: { toDebug: {
ModuleDefaultToDebug(module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
// --------------------------------------------------------
// clone -
// Clone Memopry Range // Clone Memopry Range
// //
// MemMap.MEMORY.from - Should contain the target pointer // Parameters:
// MemMap.MEMORY.dest - Should contain the destination pointer // MemMap.MEMORY.from = Should contain the target
// MemMap.MEMORY.size - Should contain the size to copy // pointer
// MemMap.MEMORY.dest = Should contain the destination
// pointer
// MemMap.MEMORY.size = Should contain the size to
// copy
// --------------------------------------------------------
clone: { clone: {
stx MemMap.MEMORY.tmpX stx MemMap.MEMORY.tmpX
sty MemMap.MEMORY.tmpY sty MemMap.MEMORY.tmpY
@ -107,11 +151,17 @@ clone: {
rts rts
} }
// --------------------------------------------------------
// fill -
// Fill Memopry Range with byte loaded in A // Fill Memopry Range with byte loaded in A
// //
// MemMap.MEMORY.dest - Should contain the destination pointer // Parameters:
// MemMap.MEMORY.size - Should contain the size to copy // MemMap.MEMORY.dest = Should contain the destination
// A - The byte to fill memory with // pointer
// MemMap.MEMORY.size = Should contain the size to
// fill
// 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
@ -144,23 +194,37 @@ fill: {
// //
// MemMap.MEMORY.dest - Should contain the destination pointer // MemMap.MEMORY.dest - Should contain the destination pointer
// MemMap.MEMORY.size - Should contain the size to copy // MemMap.MEMORY.size - Should contain the size to copy
clear: {
// --------------------------------------------------------
// clean -
// Clear Memory with 0
//
// Parameters:
// MemMap.MEMORY.dest = Should contain the destination
// pointer
// MemMap.MEMORY.size = Should contain the size to
// clean
// --------------------------------------------------------
clean: {
lda #00 lda #00
jmp Memory.fill jmp Memory.fill
} }
// ------------------------------------ // ========================================================
// DATA // ////// DATA ////////////////////////////////////////////
// ------------------------------------ // ========================================================
* = * "Memory Lib Data" * = * "Memory Lib Data"
version: .byte 1, 1, 0 module_type: .byte Module.TYPES.LIB
version: .byte 1, 1, 0
.encoding "screencode_mixed" .encoding "screencode_mixed"
module_name: module_name:
.text "lib:memory" .text "memory"
.byte 0 .byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"
#import "../core/screen.asm" #import "../core/screen.asm"

View File

@ -1,73 +1,181 @@
#importonce #importonce
#import "print.asm" #import "print.asm"
// ------------------------------------ // ========================================================
// MACROS // ////// MACROS //////////////////////////////////////////
// ------------------------------------ // ========================================================
.macro ModulePrintVersion(stringAddr) {
lda #<stringAddr // Low byte // --------------------------------------------------------
ldx #>stringAddr // High byte // ModulePrintVersion -
jsr Module.printVersion // Print out module version in the form of MAJ.MIN.REV.
// Exanple: 1.3.0.
//
// Parameters:
// versionPtr = Pointer to string Address
// --------------------------------------------------------
.macro ModulePrintVersion(versionPtr) {
lda #<versionPtr // Low byte
ldx #>versionPtr // High byte
jsr Module.printVersion
} }
.macro ModuleDefaultToDebug(module_name, version) { // --------------------------------------------------------
PrintLine(module_name) // ModulePrintType -
ModulePrintVersion(version) // Print out module Type based on Module.TYPES defs
//
// Parameters:
// versionPtr = Pointer to module type address
// --------------------------------------------------------
.macro ModulePrintType(typePtr) {
lda typePtr
jsr Module.printType
}
// --------------------------------------------------------
// ModuleToDebug -
// Print out default module information.
//
// Parameters:
// moduleType = Pointer to module type address
// moduleName = Pointer to module name address
// moduleVersion = Pointer to module version address
// --------------------------------------------------------
.macro ModuleToDebug(moduleType, moduleName, moduleVersion) {
ModulePrintType(moduleType)
lda #':'
PrintChar()
PrintLine(moduleName)
lda #$20
PrintChar()
ModulePrintVersion(moduleVersion)
PrintNewLine() PrintNewLine()
} }
.filenamespace Module .filenamespace Module
* = * "Module Lb" // ========================================================
// ////// CONSTANTS ///////////////////////////////////////
// ========================================================
// ------------------------------------ .namespace TYPES {
// METHODS .label MAIN = 00
// ------------------------------------ .label LIB = 01
.label PROG = 02
.label CORE = 03
}
* = * "Module Lib"
// ========================================================
// ////// METHODS /////////////////////////////////////////
// ========================================================
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
init: { init: {
rts rts
} }
// --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
toDebug: { toDebug: {
ModuleDefaultToDebug(module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
//------------------------------------------------------------------------------------ // --------------------------------------------------------
// printVersion -
// Print out module version
//
// Parameters:
// A = Version High Pointer
// X = Version Low Pointer
// --------------------------------------------------------
printVersion: { printVersion: {
sta MemMap.MODULE.versionPtr sta MemMap.MODULE.versionPtr
stx MemMap.MODULE.versionPtr+1 stx MemMap.MODULE.versionPtr+1
ldy #0 ldy #0
jsr printNext jsr printNext
lda #'.' lda #'.'
PrintChar() PrintChar()
jsr printNext jsr printNext
lda #'.' lda #'.'
PrintChar() PrintChar()
jsr printNext jsr printNext
rts rts
printNext: printNext:
lda (MemMap.MODULE.versionPtr), y lda (MemMap.MODULE.versionPtr), y
clc clc
adc #$30 adc #$30
PrintChar() PrintChar()
iny iny
rts rts
}
// --------------------------------------------------------
// printType -
// Print out module type based on Module Module.TYPES
//
// Parameters:
// A = Module Type
// --------------------------------------------------------
printType: {
cmp #Module.TYPES.MAIN
bne !+
PrintLine(type_main)
rts
!:
cmp #Module.TYPES.LIB
bne !+
PrintLine(type_lib)
rts
!:
cmp #Module.TYPES.CORE
bne !+
PrintLine(type_core)
rts
!:
cmp #Module.TYPES.PROG
bne !+
PrintLine(type_prog)
!:
rts
} }
// ------------------------------------ // ========================================================
// DATA // ////// DATA ////////////////////////////////////////////
// ------------------------------------ // ========================================================
* = * "Module Lib Data" * = * "Module Lib Data"
version: .byte 1, 0, 0 module_type: .byte Module.TYPES.LIB
version: .byte 1, 1, 0
.encoding "screencode_mixed" .encoding "screencode_mixed"
module_name: module_name:
.text "lib:module" .text "module"
.byte 0 .byte 0
// Modile Type Names
type_main:
.text "main"
.byte 0
type_core:
.text "core"
.byte 0
type_lib:
.text "lib"
.byte 0
type_prog:
.text "prog"
.byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"

View File

@ -4,11 +4,11 @@
#import "../core/screen.asm" #import "../core/screen.asm"
#import "../libs/module.asm" #import "../libs/module.asm"
* = * "Print Lib"
// ------------------------------------ // ========================================================
// MACROS // ////// MACROS //////////////////////////////////////////
// ------------------------------------ // ========================================================
.macro PrintLine(stringAddr) { .macro PrintLine(stringAddr) {
lda #<stringAddr // Low byte lda #<stringAddr // Low byte
ldx #>stringAddr // High byte ldx #>stringAddr // High byte
@ -25,22 +25,38 @@
.filenamespace Print .filenamespace Print
// ------------------------------------
// METHODS
// ------------------------------------
//------------------------------------------------------------------------------------ * = * "Print Lib"
// ========================================================
// ////// METHODS /////////////////////////////////////////
// ========================================================
// --------------------------------------------------------
// init -
// Module Init.
// --------------------------------------------------------
init: { init: {
rts rts
} }
//------------------------------------------------------------------------------------ // --------------------------------------------------------
// toDebug -
// Print debug info.
// --------------------------------------------------------
toDebug: { toDebug: {
ModuleDefaultToDebug(module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
//------------------------------------------------------------------------------------ // --------------------------------------------------------
// printPetChar -
// Convert a Char from PET ASCII and print it out on Screen
//
// Parameters:
// A = PET ASCII char to print
// --------------------------------------------------------
printPetChar: { printPetChar: {
pha pha
stx MemMap.SCREEN.PrintPetCharX stx MemMap.SCREEN.PrintPetCharX
@ -53,15 +69,14 @@ printPetChar: {
rts rts
} }
// // --------------------------------------------------------
// printLine // printLine -
// // Print a Null terminated SCREEN ASCII string to screen.
//
// preparatory ops: .a: low byte string address
// .x: high byte string address
// //
// returned values: none // Parameters:
// // A = low byte string address
// X = low byte string address
// --------------------------------------------------------
printLine: { printLine: {
ldy #$00 ldy #$00
sta MemMap.SCREEN.TempStringPointer sta MemMap.SCREEN.TempStringPointer
@ -76,16 +91,17 @@ printLine: {
rts rts
} }
// // --------------------------------------------------------
// btohex // byteToHex -
// // Convert a byte to an HEX value
//
// preparatory ops: .a: byte to convert
// //
// returned values: .a: msn ascii char // Parameters:
// .x: lsn ascii char // Y = Byte to Convert
// .y: entry value //
// // Result:
// A = msn ascii char result
// X = lns ascii char result
// --------------------------------------------------------
byteToHex: { byteToHex: {
pha //save byte pha //save byte
and #%00001111 //extract lsn and #%00001111 //extract lsn
@ -110,15 +126,16 @@ byteToHex: {
rts //done rts //done
} }
// --------------------------------------------------------
// // petCharToScreenChar -
// petToScreen // Convert a PET ASCII Char to a SCREEN ASCII Char
//
//
// preparatory ops: .a: pet byte to convert
// //
// returned values: .a: conv SCREEN char // Parameters:
// // A = PET ASCII Byte to Convert
//
// Result:
// A = Converted ASCII SCREEN Char
// --------------------------------------------------------
petCharToScreenChar: { petCharToScreenChar: {
// $00-$1F // $00-$1F
cmp #$1f cmp #$1f
@ -175,16 +192,18 @@ petCharToScreenChar: {
} }
// ------------------------------------ // ========================================================
// DATA // ////// DATA ////////////////////////////////////////////
// ------------------------------------ // ========================================================
* = * "Print Lib Data" * = * "Print Lib Data"
version: .byte 1, 0, 0 module_type: .byte Module.TYPES.LIB
.encoding "screencode_mixed" version: .byte 1, 0, 0
.encoding "screencode_mixed"
module_name: module_name:
.text "lib:print" .text "print"
.byte 0 .byte 0
#import "../core/mem_map.asm" #import "../core/mem_map.asm"

View File

@ -1,6 +1,6 @@
.cpu _6502 .cpu _6502
// BasicUpstart2(start) //BasicUpstart2(start)
#import "./core/mem_map.asm" #import "./core/mem_map.asm"
* = $8000 "Main" * = $8000 "Main"

View File

@ -1,16 +1,25 @@
#importonce #importonce
.filenamespace WozShell
#import "../libs/print.asm" #import "../libs/print.asm"
#import "../libs/module.asm" #import "../libs/module.asm"
#import "../core/init.asm" #import "../core/init.asm"
.filenamespace WozShell
* = * "WozShell Routines" * = * "WozShell Routines"
// ========================================================
// ////// CONSTANTS ///////////////////////////////////////
// ========================================================
.const CR = $0d .const CR = $0d
.const R = $52 .const R = $52
// ========================================================
// ////// METHODS /////////////////////////////////////////
// ========================================================
clear: clear:
init: { init: {
@ -27,8 +36,8 @@ start: {
} }
toDebug: { toDebug: {
ModuleDefaultToDebug(module_name, version) ModuleToDebug(module_type, module_name, version)
rts rts
} }
push: { push: {
@ -248,13 +257,18 @@ PRHEX: and #%00001111 // Mask LSD for hex prin
} }
//------------------------------------------------------------------------------------
// ========================================================
// ////// DATA ////////////////////////////////////////////
// ========================================================
* = * "WozShell Data" * = * "WozShell Data"
version: .byte 1, 2, 0 module_type: .byte Module.TYPES.PROG
version: .byte 1, 2, 0
.encoding "screencode_mixed" .encoding "screencode_mixed"
module_name: module_name:
.text "prg:woz-shell" .text "woz-shell"
.byte 0 .byte 0
helpString: helpString: