From e001280dc275364912deab23f55a18334c713893 Mon Sep 17 00:00:00 2001 From: Sijmen Schoon Date: Wed, 9 Dec 2020 09:01:02 +0100 Subject: [PATCH] Shuffle memory locations around a bit --- c64/day01.asm | 3 +-- c64/main.asm | 41 ++++++++++++++++++----------------------- c64/math.asm | 2 +- c64/screen.asm | 30 ++++++++++++++---------------- 4 files changed, 34 insertions(+), 42 deletions(-) diff --git a/c64/day01.asm b/c64/day01.asm index d58ad25..ef84589 100644 --- a/c64/day01.asm +++ b/c64/day01.asm @@ -18,7 +18,7 @@ .const remainder = $24 // Need to be $03 and $fd due to multiply_16bit_unsigned -.const outer_value = $03 +.const outer_value = $26 .const inner_value = $fd day01: @@ -112,7 +112,6 @@ day01: iny lda (outer_pointer), y bne !not_zero+ - .break jmp !error+ !not_zero: diff --git a/c64/main.asm b/c64/main.asm index cccb712..ab54097 100644 --- a/c64/main.asm +++ b/c64/main.asm @@ -4,29 +4,7 @@ BasicUpstart2(main) -* = $8000 - .align $100 -* = * "Square table" -square1_lo: - .fill 512, 0 -square1_hi: - .fill 512, 0 -square2_lo: - .fill 512, 0 -square2_hi: - .fill 512, 0 - -* = * "Day 01 Input" -day01_input: - .import text "../rust/inputs/day01" - .byte 0 -* = * "Day 01 Input End" - -//* = $8000 "Cartridge ROM" - -//* = $a000 "Basic ROM" - -* = $c000 "Main program" +* = $0900 "Main program" .const SCREEN_RAM = $0400 .const COLOR_RAM = $d800 @@ -72,3 +50,20 @@ buffer: #import "day01.asm" #import "screen.asm" #import "math.asm" + +* = * "Day 01 Input" +day01_input: + .import text "../rust/inputs/day01" + .byte 0 + + .align $100 +* = * "Square table" +square1_lo: + .fill 512, 0 +square1_hi: + .fill 512, 0 +square2_lo: + .fill 512, 0 +square2_hi: + .fill 512, 0 + diff --git a/c64/math.asm b/c64/math.asm index 49d69a0..cae2234 100644 --- a/c64/math.asm +++ b/c64/math.asm @@ -4,7 +4,7 @@ // Multiplication routines found on // https://codebase64.org/doku.php?id=base:seriously_fast_multiplication -.const T1=$03 +.const T1=$26 .const T2=$fd .const PRODUCT=$22 diff --git a/c64/screen.asm b/c64/screen.asm index 2370ddd..a6f7b01 100644 --- a/c64/screen.asm +++ b/c64/screen.asm @@ -107,39 +107,37 @@ write_string: ldx #0 ldy #0 -!loop: - lda ($03), y - beq !done+ + !loop: + lda ($03), y + beq !done+ - cmp #'\r' - beq !carriage_return+ - cmp #'\n' - beq !newline+ + iny - sta (cursor_pointer_lo, x) + cmp #'\r' + beq !carriage_return+ + cmp #'\n' + beq !newline+ - i16_inc(cursor_pointer_lo) - - iny + sta (cursor_pointer_lo, x) + i16_inc(cursor_pointer_lo) jmp !loop- !newline: jsr print_newline + jmp !loop- !carriage_return: jsr print_carriage_return - - iny jmp !loop- !done: rts -.macro i16_print_hex_0x(lo, hi) { - lda hi +.macro i16_print_hex_0x(addr) { + lda addr + 1 jsr print_hex_0x - lda lo + lda addr jsr print_hex }