From c415056194d6965d65c0fa18a38cdbc24660bb2c Mon Sep 17 00:00:00 2001 From: n loewen Date: Tue, 15 Aug 2023 16:59:12 +0100 Subject: [PATCH] ! Feature: Change to a 5x5 display [breaking change] --- display.js | 8 ++++---- machine.config.js | 6 +++--- readme.md | 10 +++++----- test-programs/fill-display.asm | 22 +++++++++++++--------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/display.js b/display.js index 9fe6303..6a2c1b8 100644 --- a/display.js +++ b/display.js @@ -7,8 +7,8 @@ const { num2hex } = require('./logging.js'); **/ const printDisplay = (mem) => { const disp = mem[POINTER_TO_START_OF_DISPLAY_MEM]; - for (let i = disp; i < disp + 16; i += 4) { - console.log(`${num2hex(mem[i])} ${num2hex(mem[i+1])} ${num2hex(mem[i+2])} ${num2hex(mem[i+3])}`); + for (let i = disp; i < disp + 25; i += 5) { + console.log(`${num2hex(mem[i])} ${num2hex(mem[i+1])} ${num2hex(mem[i+2])} ${num2hex(mem[i+3])} ${num2hex(mem[i+4])}`); } } @@ -19,8 +19,8 @@ const printDisplay = (mem) => { const prettyPrintDisplay = (mem) => { const disp = mem[POINTER_TO_START_OF_DISPLAY_MEM]; const num2pic = (n) => n > 0 ? '⚫' : '⚪'; - for (let i = disp; i < disp + 16; i += 4) { - console.log(`${num2pic(mem[i])}${num2pic(mem[i+1])}${num2pic(mem[i+2])}${num2pic(mem[i+3])}`); + for (let i = disp; i < disp + 25; i += 5) { + console.log(`${num2pic(mem[i])}${num2pic(mem[i])}${num2pic(mem[i+1])}${num2pic(mem[i+2])}${num2pic(mem[i+4])}`); } } diff --git a/machine.config.js b/machine.config.js index b526793..63b8bc8 100644 --- a/machine.config.js +++ b/machine.config.js @@ -1,11 +1,11 @@ module.exports = { "START_OF_DISPLAY_MEM": 0, - "POINTER_TO_START_OF_DISPLAY_MEM": 32, - "POINTER_TO_START_OF_KEYPAD_MEM": 33, + "POINTER_TO_START_OF_DISPLAY_MEM": 33, + "POINTER_TO_START_OF_KEYPAD_MEM": 34, "INITIAL_IP_ADDRESS": 48, // max number of times to step the CPU, // to stop endless loops // 0 = infinite - "CYCLE_LIMIT": 128, + "CYCLE_LIMIT": 256, } \ No newline at end of file diff --git a/readme.md b/readme.md index 20c9b12..6bb9b1d 100644 --- a/readme.md +++ b/readme.md @@ -62,11 +62,11 @@ With verbose debugging output: ## Memory map / Peripherals -- `00-0F` - display (4x4) -- `10-1F` - keypad? (details TBD) -- `20 ` - pointer to display memory -- `21 ` - pointer to keypad memory -- `22-2F` - reserved for future use / variable storage +- `00-19` - display (5x5) +- `20 ` - keypad (details TBD) +- `21 ` - pointer to display memory +- `22 ` - pointer to keypad memory +- `23-2F` - reserved for future use / variable storage - `30 ` - initial value for IP - `30-FF` - free diff --git a/test-programs/fill-display.asm b/test-programs/fill-display.asm index aa09e53..1d7f36a 100644 --- a/test-programs/fill-display.asm +++ b/test-programs/fill-display.asm @@ -1,23 +1,27 @@ ;; Fill display with $FF +; updated for 5x5 display + +=pixelIndex $24 +=pixelFill $25 LDA $00 ; Start of display -STO $21 ; Pixel index +STO =pixelIndex -; store the $FF that we'll use to fill the screen LDA $FF -STO $22 +STO =pixelFill @copy-to-display - LDA ($22) ; A = mem[$22] = $FF - STO ($21) ; mem[mem[$21]] = A = $FF + LDA ($25) ; A = mem[$25] = $FF + STO ($24) ; update pixel ... mem[mem[$24]] = A = $FF ; increment pixel index -LDA ($21) +LDA ($24) ADD $01 -STO $21 +STO =pixelIndex -; if CF is set, then the display is full and we're done -FHP 0 +LDA ($24) ; pixelIndex +SUB $19 ; if pixelIndex - $19 == 0, we've reached the end +FHP 2 ; Zero flag is #2 JMP @copy-to-display END \ No newline at end of file