From: Bernard Blackham Date: Fri, 15 Aug 2003 16:41:04 +0000 (+0000) Subject: Rewrite of delay function X-Git-Tag: ROMW~58 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=8436ed0d04bf12d2478bffbe3ea45531fa954686;p=uccvend-snackrom.git Rewrite of delay function Riddance of print amount function (not needed for basic setup) --- diff --git a/ROM2/helpers.c b/ROM2/helpers.c index a35073c..b66f5ee 100644 --- a/ROM2/helpers.c +++ b/ROM2/helpers.c @@ -1,23 +1,32 @@ #include "display_basic.h" #include "vend.h" -#define DELAY_MAGIC 20 /* FIXME: number of loops for ~ 1 millisecond (< 256) */ void delay(u16 ms) { - u8 i; - for (;ms;ms--) { - for (i=0;i asm, but before asm -> machine code. + */ + asm volatile ("pshx\npsha\npshb\n"); /* save registers */ + asm volatile ("ldx %0\n" :: "m" (ms)); + asm volatile ( + "loop:\n" + " dex\n" /* 3 */ + " beq out\n" /* 3 */ + " ldd #327\n" /* 3 */ + "inner_loop:\n" /* 15 cycles each */ + " cpd #0x0000\n" /* 5 */ + " beq inner_loop_end\n" /* 3 */ + " subd #0x0001\n" /* 4 */ + " bra inner_loop\n" /* 3 */ + "inner_loop_end:\n" + " bra loop\n" /* 3 */ + "out:\n" + " pulb\n" + " pula\n" + " pulx\n"); } void my_strncpy(char* dst, char* src, u8 max_size) { diff --git a/ROM2/vectors.s b/ROM2/vectors.s index f420128..f8f586d 100644 --- a/ROM2/vectors.s +++ b/ROM2/vectors.s @@ -35,8 +35,8 @@ Boston, MA 02111-1307, USA. */ def: rti - .globl _debug_user_vectors -_debug_user_vectors = 0 +;; .globl _debug_user_vectors +;;_debug_user_vectors = 0 ;; RTI interrupt handler diff --git a/ROM2/vend.h b/ROM2/vend.h index 9922719..f3b0e65 100644 --- a/ROM2/vend.h +++ b/ROM2/vend.h @@ -30,7 +30,6 @@ extern u16 _stack; /******* from helpers.c *******/ void delay(u16 ms); -void print_amount(u16 amt); void my_strncpy(char* dst, char* src, u8 max_size); /* for null-term strings */ void my_memcpy(char* dst, char* src, u8 size);