Milestone 3.5, tiles and sprites both present on the screen. Also started breaking the code out into libraries for easier editing and maintenance.

This commit is contained in:
2012-11-06 23:30:20 -05:00
parent 38e8607572
commit d17de5971c
5 changed files with 296 additions and 104 deletions

28
include/math.S Normal file
View File

@@ -0,0 +1,28 @@
;; Function : divide
;;
;; Divide the value in A by the value in Y
;; The dividend is returned in A
;; The modulus is returned in Y
divide:
.invoke storeStackReturn
sta tempdivident ;Stores divident
sty tempdivisor ;Stores divisor
lda #$00
sta tempdivresult ;Clear result
ldy #$10 ;The loop is for 16-bit result
_divide_loop:
asl tempdivident
rol ;Shift divisor in 1 bit
cmp tempdivisor ;Check if fractional dividend is greater than divisor
bcc _divide_subloop
sbc tempdivisor ;Substract (C is always set)
_divide_subloop:
rol tempdivresult ;Shift result (1 if substation was done, 0 otherwise)
rol tempdivmodulus
dey
bne _divide_loop
lda tempdivresult
ldy tempdivmodulus
.invoke restoreStackReturn
RTS