aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--console.s27
-rw-r--r--taipan.c31
2 files changed, 49 insertions, 9 deletions
diff --git a/console.s b/console.s
index 7837ce1..1930303 100644
--- a/console.s
+++ b/console.s
@@ -138,7 +138,32 @@ _rvs_off:
; ...or 5 bytes each. we have 5 of them, so 25 bytes. using fall-thru
; and the BIT trick, they condense down to 17 bytes.
; if you're not familiar with the "BIT trick" to skip a 2-byte instruction,
- ; the stuff below looks like gibberish, sorry.
+ ; the stuff below looks like gibberish... here's a mini-tutorial:
+
+ ;store1:
+ ; lda #1
+ ; .byte $2c ; this is the opcode for BIT absolute
+ ;store2:
+ ; lda #2
+ ; sta $0600
+ ; rts
+
+ ; if entered via "jsr store1", the above code fragment executes these
+ ; instructions:
+ ; lda #1
+ ; bit $02A9 ; $A9 is the LDA immediate opcode, 02 is the #2
+ ; sta $0600
+ ; rts
+
+ ; if entered via "jsr store2", it's
+ ; lda #2
+ ; sta $0600
+ ; rts
+
+ ; the "bit $02a9' doesn't affect any registers other than the flags,
+ ; and the "sta $0600 : rts" part doesn't depend on any of the flags,
+ ; so the BIT is effectively a no-op that "masks" the 2-byte LDA #2
+ ; instruction "hidden" as its operand.
; ", Taipan? "
; using fall-thru here saves 3 bytes (normally the last instruction
diff --git a/taipan.c b/taipan.c
index e221fc5..ef10068 100644
--- a/taipan.c
+++ b/taipan.c
@@ -316,7 +316,7 @@ unsigned long __fastcall__ strtonum(const char* nptr);
unsigned char firmpos;
-/* use page 6 for these buffers, for .xex build. Otherwise they'e BSS. */
+/* use page 6 for these buffers, for .xex build. Otherwise they're BSS. */
#ifdef CART_TARGET
char firm[23];
char num_buf[20];
@@ -779,15 +779,17 @@ void new_gun(void) {
return;
}
+/* cprintfancy_centered() does this for 0 to 999999:
+ | 999999 |
+ | 99999 |
+ | 9999 |
+ | 999 |
+ | 99 |
+ | 9 | */
+
+#if 0
void cprintfancy_centered(unsigned long num) {
if(num < 1000000L) {
- /* 0 to 999999:
- | 999999 |
- | 99999 |
- | 9999 |
- | 999 |
- | 99 |
- | 9 | */
cspaces(3);
if(num < 100L) cspace();
if(num < 10000L) cspace();
@@ -799,6 +801,19 @@ void cprintfancy_centered(unsigned long num) {
}
rvs_off();
}
+#else
+// saves 12 bytes:
+void cprintfancy_centered(unsigned long num) {
+ if(num < 1000000L) {
+ cspaces(3);
+ if(num < 100L) cspace();
+ if(num < 10000L) cspace();
+ }
+ rvs_on();
+ cprintfancy(num);
+ rvs_off();
+}
+#endif
/* if BIGNUM, cprintfancy() just converts to bignum and uses
cprintfancy_big() to do the work. A bit slower, but fast