mirror of
https://github.com/stid/woz64.git
synced 2025-04-05 19:37:10 +00:00
Cleanup & Standardize code
This commit is contained in:
parent
411f75b5aa
commit
222326bb1a
@ -5,16 +5,22 @@
|
||||
#import "../libs/print.asm"
|
||||
#import "../core/keyboard.asm"
|
||||
#import "../core/screen.asm"
|
||||
#import "../libs/module.asm"
|
||||
#import "../progs/woz_shell.asm"
|
||||
|
||||
.filenamespace Init
|
||||
|
||||
* = * "Init Core"
|
||||
|
||||
// ------------------------------------
|
||||
// METHODS
|
||||
// ------------------------------------
|
||||
|
||||
// ========================================================
|
||||
// ////// METHODS /////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
// --------------------------------------------------------
|
||||
// init -
|
||||
// Module Init.
|
||||
// --------------------------------------------------------
|
||||
init: {
|
||||
// Init All Modules
|
||||
jsr Memory.init
|
||||
@ -27,9 +33,13 @@ init: {
|
||||
rts
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// toDebug -
|
||||
// Print debug info.
|
||||
// --------------------------------------------------------
|
||||
toDebug: {
|
||||
// Debug All Modules
|
||||
ModuleDefaultToDebug(module_name, version)
|
||||
ModuleToDebug(module_type, module_name, version)
|
||||
jsr Keyboard.toDebug
|
||||
jsr Screen.toDebug
|
||||
jsr Module.toDebug
|
||||
@ -42,14 +52,19 @@ toDebug: {
|
||||
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// DATA
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// 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:
|
||||
.text "core:init"
|
||||
.text "init"
|
||||
.byte 0
|
||||
|
||||
|
||||
#import "../core/mem_map.asm"
|
||||
|
||||
|
@ -1,30 +1,33 @@
|
||||
#importonce
|
||||
#import "../libs/module.asm"
|
||||
#import "../libs/memory.asm"
|
||||
|
||||
// ------------------------------------
|
||||
// MACROS
|
||||
// ------------------------------------
|
||||
#import "../libs/module.asm"
|
||||
|
||||
|
||||
.filenamespace Keyboard
|
||||
|
||||
|
||||
* = * "Keyboard Module"
|
||||
// ------------------------------------
|
||||
// CONSTANTS
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// CONSTANTS ///////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
|
||||
.const CIA1_KeybWrite = $DC00
|
||||
.const CIA1_KeybRead = $DC01
|
||||
|
||||
.const cSYS_DelayValue = 32
|
||||
.const cKeybW_Row1 = $FE
|
||||
|
||||
* = * "Keyboard Module"
|
||||
|
||||
// ------------------------------------
|
||||
// METHODS
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// METHODS ROM /////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
// --------------------------------------------------------
|
||||
// init -
|
||||
// Module Init.
|
||||
// --------------------------------------------------------
|
||||
init: {
|
||||
lda #64
|
||||
sta MemMap.KEYBOARD.SYS_Lstx
|
||||
@ -45,16 +48,24 @@ init: {
|
||||
lda #10
|
||||
sta MemMap.KEYBOARD.SYS_Xmax
|
||||
|
||||
// CLODE TO RAM
|
||||
// Clone self altering Methods to RAM
|
||||
MemoryClone(cloneStart, cloneEnd, $1000)
|
||||
rts
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// toDebug -
|
||||
// Print debug info.
|
||||
// --------------------------------------------------------
|
||||
toDebug: {
|
||||
ModuleDefaultToDebug(module_name, version)
|
||||
ModuleToDebug(module_type, module_name, version)
|
||||
rts
|
||||
}
|
||||
|
||||
// ========================================================
|
||||
// ////// KEYMAPPING RON //////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
KeyMapVec:
|
||||
.word KeyMap1, KeyMap2, KeyMap3, KeyMap4
|
||||
|
||||
@ -107,15 +118,32 @@ KeyMap4:
|
||||
.byte $FF
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// RAM METHODS
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// METHODS RAM /////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
* = * "Keyboard Ram"
|
||||
|
||||
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 {
|
||||
ReadKeyb:
|
||||
lda #<KeyMap1
|
||||
@ -251,7 +279,14 @@ ReadKeyb:
|
||||
sta @SMC_Key + 2
|
||||
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
|
||||
bne @IsKey
|
||||
|
||||
@ -276,14 +311,19 @@ GetKey: lda MemMap.KEYBOARD.SYS_Ndx
|
||||
|
||||
cloneEnd:
|
||||
|
||||
// ------------------------------------
|
||||
// DATA
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// 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:
|
||||
.text "core:keyboard"
|
||||
.text "keyboard"
|
||||
.byte 0
|
||||
|
||||
|
||||
#import "../core/mem_map.asm"
|
||||
|
||||
|
121
core/screen.asm
121
core/screen.asm
@ -3,12 +3,22 @@
|
||||
#import "../libs/memory.asm"
|
||||
#import "../libs/module.asm"
|
||||
|
||||
// ------------------------------------
|
||||
// MACROS
|
||||
// ------------------------------------
|
||||
|
||||
// ========================================================
|
||||
// ////// MACROS //////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
|
||||
* = * "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) {
|
||||
lda #clearByte
|
||||
ldx #0
|
||||
@ -22,52 +32,95 @@
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ScreenClear -
|
||||
// Fast clear screen characters mem.
|
||||
//
|
||||
// Parameters:
|
||||
// clearByte = Byte to use to clear screen
|
||||
// --------------------------------------------------------
|
||||
.macro ScreenClear(clearByte) {
|
||||
ScreenClearChunks(Screen.VIDEO_ADDR, clearByte)
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ScreenClear -
|
||||
// Fast clear screen Color Ram.
|
||||
//
|
||||
// Parameters:
|
||||
// clearByte = Byte to use to clear screen
|
||||
// --------------------------------------------------------
|
||||
.macro ScreenClearColorRam(clearByte) {
|
||||
ScreenClearChunks(Screen.COLOR_ADDR, clearByte)
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ScreenSetBorderColor -
|
||||
// Set Screen border color.
|
||||
//
|
||||
// Parameters:
|
||||
// color = https://www.c64-wiki.com/wiki/Color
|
||||
// --------------------------------------------------------
|
||||
.macro ScreenSetBorderColor(color) {
|
||||
lda #color
|
||||
sta $d020
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ScreenSetBackgroundColor -
|
||||
// Set Screen Backfground color.
|
||||
//
|
||||
// Parameters:
|
||||
// color = https://www.c64-wiki.com/wiki/Color
|
||||
// --------------------------------------------------------
|
||||
.macro ScreenSetBackgroundColor(color) {
|
||||
lda #color
|
||||
sta $d021
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ScreenSetMultiColor1 -
|
||||
// Set Screen Muticolor 1.
|
||||
//
|
||||
// Parameters:
|
||||
// color = https://www.c64-wiki.com/wiki/Color
|
||||
// --------------------------------------------------------
|
||||
.macro ScreenSetMultiColor1(color) {
|
||||
lda #color
|
||||
sta $d022
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ScreenSetMultiColor2 -
|
||||
// Set Screen Muticolor 2.
|
||||
//
|
||||
// Parameters:
|
||||
// color = https://www.c64-wiki.com/wiki/Color
|
||||
// --------------------------------------------------------
|
||||
.macro ScreenSetMultiColor2(color) {
|
||||
lda #color
|
||||
sta $d023
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ScreenSetMultiColorMode -
|
||||
// Set Screen Muticolor 2.
|
||||
//
|
||||
// Parameters:
|
||||
// color = https://www.c64-wiki.com/wiki/Multicolor_Bitmap_Mode
|
||||
// --------------------------------------------------------
|
||||
.macro ScreenSetMultiColorMode() {
|
||||
lda $d016
|
||||
ora #16
|
||||
sta $d016
|
||||
}
|
||||
|
||||
.macro ScreenSetScrollMode() {
|
||||
lda $D016
|
||||
eor #%00001000
|
||||
sta $D016
|
||||
}
|
||||
|
||||
.filenamespace Screen
|
||||
|
||||
// ========================================================
|
||||
// ////// CONSTANTS ///////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
// ------------------------------------
|
||||
// COSTANTS
|
||||
// ------------------------------------
|
||||
.label VIDEO_ADDR = $0400
|
||||
.label COLOR_ADDR = $D800
|
||||
.label COLUMN_NUM = 40
|
||||
@ -76,11 +129,15 @@
|
||||
.label BS = $95
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// METHODS
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// METHODS /////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// --------------------------------------------------------
|
||||
// init -
|
||||
// Module Init.
|
||||
// --------------------------------------------------------
|
||||
init: {
|
||||
lda #$00
|
||||
sta MemMap.SCREEN.CursorCol
|
||||
@ -88,12 +145,19 @@ init: {
|
||||
rts
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// toDebug -
|
||||
// Print debug info.
|
||||
// --------------------------------------------------------
|
||||
toDebug: {
|
||||
ModuleDefaultToDebug(module_name, version)
|
||||
ModuleToDebug(module_type, module_name, version)
|
||||
rts
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// --------------------------------------------------------
|
||||
// scrollUp -
|
||||
// Scroll the entire screen UP - 1 line
|
||||
// --------------------------------------------------------
|
||||
scrollUp: {
|
||||
pha
|
||||
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: {
|
||||
sei
|
||||
stx MemMap.SCREEN.tempX
|
||||
@ -195,7 +266,11 @@ sendChar: {
|
||||
rts
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// --------------------------------------------------------
|
||||
// screenNewLine -
|
||||
// Insert a New Line to screen - auto handle screen bottom
|
||||
// linit scroll.
|
||||
// --------------------------------------------------------
|
||||
screenNewLine: {
|
||||
pha
|
||||
lda #0
|
||||
@ -216,11 +291,11 @@ screenNewLine: {
|
||||
rts
|
||||
}
|
||||
|
||||
|
||||
* = * "Screen Module Data"
|
||||
version: .byte 1, 0, 0
|
||||
module_type: .byte Module.TYPES.CORE
|
||||
version: .byte 1, 0, 0
|
||||
module_name:
|
||||
.text "core:screen"
|
||||
.text "screen"
|
||||
.byte 0
|
||||
|
||||
#import "../core/mem_map.asm"
|
||||
|
@ -1,30 +1,46 @@
|
||||
|
||||
#importonce
|
||||
#import "../libs/module.asm"
|
||||
|
||||
// ------------------------------------
|
||||
// MACROS
|
||||
// ------------------------------------
|
||||
#import "../libs/module.asm"
|
||||
|
||||
|
||||
.filenamespace Math
|
||||
|
||||
* = * "Math Lin"
|
||||
|
||||
// ------------------------------------
|
||||
// METHODS
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// METHODS /////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// init -
|
||||
// Module Init.
|
||||
// --------------------------------------------------------
|
||||
init: {
|
||||
rts
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// toDebug -
|
||||
// Print debug info.
|
||||
// --------------------------------------------------------
|
||||
toDebug: {
|
||||
ModuleDefaultToDebug(module_name, version)
|
||||
ModuleToDebug(module_type, module_name, version)
|
||||
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: {
|
||||
sei
|
||||
pha
|
||||
@ -54,15 +70,17 @@ multiply: {
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// DATA
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// DATA ////////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
* = * "Math Lib Data"
|
||||
version: .byte 1, 1, 0
|
||||
module_type: .byte Module.TYPES.LIB
|
||||
version: .byte 1, 1, 0
|
||||
|
||||
.encoding "screencode_mixed"
|
||||
module_name:
|
||||
.text "lib:math"
|
||||
.text "math"
|
||||
.byte 0
|
||||
|
||||
|
||||
|
106
libs/memory.asm
106
libs/memory.asm
@ -1,14 +1,22 @@
|
||||
|
||||
#importonce
|
||||
#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) {
|
||||
lda #<from
|
||||
sta MemMap.MEMORY.from
|
||||
@ -28,6 +36,15 @@
|
||||
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) {
|
||||
lda #<from
|
||||
sta MemMap.MEMORY.from
|
||||
@ -43,6 +60,14 @@
|
||||
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) {
|
||||
lda #<from
|
||||
sta MemMap.MEMORY.from
|
||||
@ -57,27 +82,46 @@
|
||||
jsr Memory.clear
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
// METHODS
|
||||
// ------------------------------------
|
||||
|
||||
.filenamespace Memory
|
||||
|
||||
* = * "Memory Lib"
|
||||
|
||||
// ========================================================
|
||||
// ////// METHODS /////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// init -
|
||||
// Module Init.
|
||||
// --------------------------------------------------------
|
||||
init: {
|
||||
rts
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// toDebug -
|
||||
// Print debug info.
|
||||
// --------------------------------------------------------
|
||||
toDebug: {
|
||||
ModuleDefaultToDebug(module_name, version)
|
||||
ModuleToDebug(module_type, module_name, version)
|
||||
rts
|
||||
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// clone -
|
||||
// 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
|
||||
// Parameters:
|
||||
// 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: {
|
||||
stx MemMap.MEMORY.tmpX
|
||||
sty MemMap.MEMORY.tmpY
|
||||
@ -107,11 +151,17 @@ clone: {
|
||||
rts
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// fill -
|
||||
// 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
|
||||
// Parameters:
|
||||
// MemMap.MEMORY.dest = Should contain the destination
|
||||
// pointer
|
||||
// MemMap.MEMORY.size = Should contain the size to
|
||||
// fill
|
||||
// A = The byte to fill memory with
|
||||
// --------------------------------------------------------
|
||||
fill: {
|
||||
stx MemMap.MEMORY.tmpX
|
||||
sty MemMap.MEMORY.tmpY
|
||||
@ -144,23 +194,37 @@ fill: {
|
||||
//
|
||||
// MemMap.MEMORY.dest - Should contain the destination pointer
|
||||
// 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
|
||||
jmp Memory.fill
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// DATA
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// DATA ////////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
* = * "Memory Lib Data"
|
||||
version: .byte 1, 1, 0
|
||||
module_type: .byte Module.TYPES.LIB
|
||||
version: .byte 1, 1, 0
|
||||
|
||||
.encoding "screencode_mixed"
|
||||
module_name:
|
||||
.text "lib:memory"
|
||||
.text "memory"
|
||||
.byte 0
|
||||
|
||||
|
||||
#import "../core/mem_map.asm"
|
||||
#import "../core/screen.asm"
|
||||
|
||||
|
172
libs/module.asm
172
libs/module.asm
@ -1,73 +1,181 @@
|
||||
#importonce
|
||||
#import "print.asm"
|
||||
|
||||
// ------------------------------------
|
||||
// MACROS
|
||||
// ------------------------------------
|
||||
.macro ModulePrintVersion(stringAddr) {
|
||||
lda #<stringAddr // Low byte
|
||||
ldx #>stringAddr // High byte
|
||||
jsr Module.printVersion
|
||||
// ========================================================
|
||||
// ////// MACROS //////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
// --------------------------------------------------------
|
||||
// ModulePrintVersion -
|
||||
// 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)
|
||||
ModulePrintVersion(version)
|
||||
// --------------------------------------------------------
|
||||
// ModulePrintType -
|
||||
// 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()
|
||||
}
|
||||
|
||||
|
||||
.filenamespace Module
|
||||
|
||||
* = * "Module Lb"
|
||||
// ========================================================
|
||||
// ////// CONSTANTS ///////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
// ------------------------------------
|
||||
// METHODS
|
||||
// ------------------------------------
|
||||
.namespace TYPES {
|
||||
.label MAIN = 00
|
||||
.label LIB = 01
|
||||
.label PROG = 02
|
||||
.label CORE = 03
|
||||
}
|
||||
|
||||
|
||||
* = * "Module Lib"
|
||||
|
||||
// ========================================================
|
||||
// ////// METHODS /////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
// --------------------------------------------------------
|
||||
// init -
|
||||
// Module Init.
|
||||
// --------------------------------------------------------
|
||||
init: {
|
||||
rts
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// toDebug -
|
||||
// Print debug info.
|
||||
// --------------------------------------------------------
|
||||
toDebug: {
|
||||
ModuleDefaultToDebug(module_name, version)
|
||||
ModuleToDebug(module_type, module_name, version)
|
||||
rts
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// --------------------------------------------------------
|
||||
// printVersion -
|
||||
// Print out module version
|
||||
//
|
||||
// Parameters:
|
||||
// A = Version High Pointer
|
||||
// X = Version Low Pointer
|
||||
// --------------------------------------------------------
|
||||
printVersion: {
|
||||
sta MemMap.MODULE.versionPtr
|
||||
stx MemMap.MODULE.versionPtr+1
|
||||
ldy #0
|
||||
jsr printNext
|
||||
lda #'.'
|
||||
sta MemMap.MODULE.versionPtr
|
||||
stx MemMap.MODULE.versionPtr+1
|
||||
ldy #0
|
||||
jsr printNext
|
||||
lda #'.'
|
||||
PrintChar()
|
||||
jsr printNext
|
||||
lda #'.'
|
||||
jsr printNext
|
||||
lda #'.'
|
||||
PrintChar()
|
||||
jsr printNext
|
||||
jsr printNext
|
||||
rts
|
||||
printNext:
|
||||
lda (MemMap.MODULE.versionPtr), y
|
||||
lda (MemMap.MODULE.versionPtr), y
|
||||
clc
|
||||
adc #$30
|
||||
adc #$30
|
||||
PrintChar()
|
||||
iny
|
||||
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"
|
||||
version: .byte 1, 0, 0
|
||||
module_type: .byte Module.TYPES.LIB
|
||||
version: .byte 1, 1, 0
|
||||
|
||||
.encoding "screencode_mixed"
|
||||
module_name:
|
||||
.text "lib:module"
|
||||
.byte 0
|
||||
.text "module"
|
||||
.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"
|
||||
|
||||
|
105
libs/print.asm
105
libs/print.asm
@ -4,11 +4,11 @@
|
||||
#import "../core/screen.asm"
|
||||
#import "../libs/module.asm"
|
||||
|
||||
* = * "Print Lib"
|
||||
|
||||
// ------------------------------------
|
||||
// MACROS
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// MACROS //////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
.macro PrintLine(stringAddr) {
|
||||
lda #<stringAddr // Low byte
|
||||
ldx #>stringAddr // High byte
|
||||
@ -25,22 +25,38 @@
|
||||
|
||||
|
||||
.filenamespace Print
|
||||
// ------------------------------------
|
||||
// METHODS
|
||||
// ------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
* = * "Print Lib"
|
||||
|
||||
// ========================================================
|
||||
// ////// METHODS /////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
|
||||
// --------------------------------------------------------
|
||||
// init -
|
||||
// Module Init.
|
||||
// --------------------------------------------------------
|
||||
init: {
|
||||
rts
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// --------------------------------------------------------
|
||||
// toDebug -
|
||||
// Print debug info.
|
||||
// --------------------------------------------------------
|
||||
toDebug: {
|
||||
ModuleDefaultToDebug(module_name, version)
|
||||
ModuleToDebug(module_type, module_name, version)
|
||||
rts
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// --------------------------------------------------------
|
||||
// printPetChar -
|
||||
// Convert a Char from PET ASCII and print it out on Screen
|
||||
//
|
||||
// Parameters:
|
||||
// A = PET ASCII char to print
|
||||
// --------------------------------------------------------
|
||||
printPetChar: {
|
||||
pha
|
||||
stx MemMap.SCREEN.PrintPetCharX
|
||||
@ -53,15 +69,14 @@ printPetChar: {
|
||||
rts
|
||||
}
|
||||
|
||||
// ——————————————————————————————————————————————————————
|
||||
// printLine
|
||||
// ——————————————————————————————————————————————————————
|
||||
// ——————————————————————————————————————————————————————
|
||||
// preparatory ops: .a: low byte string address
|
||||
// .x: high byte string address
|
||||
// --------------------------------------------------------
|
||||
// printLine -
|
||||
// Print a Null terminated SCREEN ASCII string to screen.
|
||||
//
|
||||
// returned values: none
|
||||
// ——————————————————————————————————————————————————————
|
||||
// Parameters:
|
||||
// A = low byte string address
|
||||
// X = low byte string address
|
||||
// --------------------------------------------------------
|
||||
printLine: {
|
||||
ldy #$00
|
||||
sta MemMap.SCREEN.TempStringPointer
|
||||
@ -76,16 +91,17 @@ printLine: {
|
||||
rts
|
||||
}
|
||||
|
||||
// ————————————————————————————————————
|
||||
// btohex
|
||||
// ————————————————————————————————————
|
||||
// ————————————————————————————————————
|
||||
// preparatory ops: .a: byte to convert
|
||||
// --------------------------------------------------------
|
||||
// byteToHex -
|
||||
// Convert a byte to an HEX value
|
||||
//
|
||||
// returned values: .a: msn ascii char
|
||||
// .x: lsn ascii char
|
||||
// .y: entry value
|
||||
// ————————————————————————————————————
|
||||
// Parameters:
|
||||
// Y = Byte to Convert
|
||||
//
|
||||
// Result:
|
||||
// A = msn ascii char result
|
||||
// X = lns ascii char result
|
||||
// --------------------------------------------------------
|
||||
byteToHex: {
|
||||
pha //save byte
|
||||
and #%00001111 //extract lsn
|
||||
@ -110,15 +126,16 @@ byteToHex: {
|
||||
rts //done
|
||||
}
|
||||
|
||||
|
||||
// ————————————————————————————————————————
|
||||
// petToScreen
|
||||
// ————————————————————————————————————————
|
||||
// ————————————————————————————————————————
|
||||
// preparatory ops: .a: pet byte to convert
|
||||
// --------------------------------------------------------
|
||||
// petCharToScreenChar -
|
||||
// Convert a PET ASCII Char to a SCREEN ASCII Char
|
||||
//
|
||||
// returned values: .a: conv SCREEN char
|
||||
// ————————————————————————————————————————
|
||||
// Parameters:
|
||||
// A = PET ASCII Byte to Convert
|
||||
//
|
||||
// Result:
|
||||
// A = Converted ASCII SCREEN Char
|
||||
// --------------------------------------------------------
|
||||
petCharToScreenChar: {
|
||||
// $00-$1F
|
||||
cmp #$1f
|
||||
@ -175,16 +192,18 @@ petCharToScreenChar: {
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------
|
||||
// DATA
|
||||
// ------------------------------------
|
||||
// ========================================================
|
||||
// ////// DATA ////////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
* = * "Print Lib Data"
|
||||
version: .byte 1, 0, 0
|
||||
.encoding "screencode_mixed"
|
||||
module_type: .byte Module.TYPES.LIB
|
||||
version: .byte 1, 0, 0
|
||||
|
||||
.encoding "screencode_mixed"
|
||||
module_name:
|
||||
.text "lib:print"
|
||||
.byte 0
|
||||
.text "print"
|
||||
.byte 0
|
||||
|
||||
#import "../core/mem_map.asm"
|
||||
|
||||
|
2
main.asm
2
main.asm
@ -1,6 +1,6 @@
|
||||
.cpu _6502
|
||||
|
||||
// BasicUpstart2(start)
|
||||
//BasicUpstart2(start)
|
||||
#import "./core/mem_map.asm"
|
||||
|
||||
* = $8000 "Main"
|
||||
|
@ -1,16 +1,25 @@
|
||||
#importonce
|
||||
.filenamespace WozShell
|
||||
|
||||
#import "../libs/print.asm"
|
||||
#import "../libs/module.asm"
|
||||
#import "../core/init.asm"
|
||||
|
||||
.filenamespace WozShell
|
||||
|
||||
* = * "WozShell Routines"
|
||||
|
||||
// ========================================================
|
||||
// ////// CONSTANTS ///////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
.const CR = $0d
|
||||
.const R = $52
|
||||
|
||||
|
||||
// ========================================================
|
||||
// ////// METHODS /////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
|
||||
clear:
|
||||
init: {
|
||||
|
||||
@ -27,8 +36,8 @@ start: {
|
||||
}
|
||||
|
||||
toDebug: {
|
||||
ModuleDefaultToDebug(module_name, version)
|
||||
rts
|
||||
ModuleToDebug(module_type, module_name, version)
|
||||
rts
|
||||
}
|
||||
|
||||
push: {
|
||||
@ -248,13 +257,18 @@ PRHEX: and #%00001111 // Mask LSD for hex prin
|
||||
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
// ========================================================
|
||||
// ////// DATA ////////////////////////////////////////////
|
||||
// ========================================================
|
||||
|
||||
* = * "WozShell Data"
|
||||
version: .byte 1, 2, 0
|
||||
module_type: .byte Module.TYPES.PROG
|
||||
version: .byte 1, 2, 0
|
||||
|
||||
.encoding "screencode_mixed"
|
||||
module_name:
|
||||
.text "prg:woz-shell"
|
||||
.text "woz-shell"
|
||||
.byte 0
|
||||
|
||||
helpString:
|
||||
|
Loading…
x
Reference in New Issue
Block a user