changeset 19:041427f5faf9

Change SWI routines to just proper jump table Change the routine vector table for SWI calls to use a proper jump table instead of a sequence of offsets from the previous routine. This allows the routines to be reorganized and makes access to the routines run faster. This does have an impact on game play because less time is taken looking up routine addresses.
author William Astle <lost@l-w.ca>
date Thu, 01 Jan 2015 22:16:32 -0700
parents 78f1cbcf49b9
children 76b87449de65
files dod.s
diffstat 1 files changed, 35 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/dod.s	Thu Jan 01 21:09:08 2015 -0700
+++ b/dod.s	Thu Jan 01 22:16:32 2015 -0700
@@ -869,18 +869,15 @@
 ; SWI handler
 swisvc		andcc #$ef			; re-enable IRQ - SWI disables it
 		ldx 10,s			; get return address
-		lda ,x+				; get operation code
+		ldb ,x+				; get operation code
 		stx 10,s			; save new return address
-		ldx #LC384			; point to first SWI routine
-		ldu #LC995			; point to routine offset table
-LC360		ldb ,u+				; get length of previous routine
-		abx				; add to routine pointer
-		deca				; are we at the right routine?
-		bpl LC360			; brif not
+		ldx #swijump			; point to jump table
+		abx				;* offset to correct routine
+		abx				;*
+		ldx ,x				; fetch routine address
 		stx ,--s			; save routine address
-		ldd 3,s				; restore D register
+		ldb 4,s				; restore D register
 		ldx 6,s				; restore X register
-		ldu 10,s			; restore U register
 		jsr [,s++]			; call the routine
 		rti				; return to caller
 ; SWI 0 routine
@@ -1852,35 +1849,35 @@
 		bra LC984			; go deal with multiplier
 ; this is the swi routine offset table - each byte is the difference between the entry point
 ; of the previous routine and itself
-LC995		fcb 0				; first routine has nothing before it
-		fcb LC3A2-LC384
-		fcb LC448-LC3A2
-		fcb LC454-LC448
-		fcb LC459-LC454
-		fcb LC46F-LC459
-		fcb LC472-LC46F
-		fcb LC4CF-LC472
-		fcb LC4F3-LC4CF
-		fcb LC4F6-LC4F3
-		fcb LC4FF-LC4F6
-		fcb LC507-LC4FF
-		fcb LC529-LC507
-		fcb LC5D9-LC529
-		fcb LC656-LC5D9
-		fcb LC674-LC656
-		fcb LC67F-LC674
-		fcb LC686-LC67F
-		fcb LC688-LC686
-		fcb LC6A4-LC688
-		fcb LC6A8-LC6A4
-		fcb LC6C5-LC6A8
-		fcb LC6E6-LC6C5
-		fcb LC6FB-LC6E6
-		fcb LC71F-LC6FB
-		fcb LC743-LC71F
-		fcb LC759-LC743
-		fcb LC7C8-LC759
-		fcb LC7D0-LC7C8
+swijump		fdb LC384
+		fdb LC3A2
+		fdb LC448
+		fdb LC454
+		fdb LC459
+		fdb LC46F
+		fdb LC472
+		fdb LC4CF
+		fdb LC4F3
+		fdb LC4F6
+		fdb LC4FF
+		fdb LC507
+		fdb LC529
+		fdb LC5D9
+		fdb LC656
+		fdb LC674
+		fdb LC67F
+		fdb LC686
+		fdb LC688
+		fdb LC6A4
+		fdb LC6A8
+		fdb LC6C5
+		fdb LC6E6
+		fdb LC6FB
+		fdb LC71F
+		fdb LC743
+		fdb LC759
+		fdb LC7C8
+		fdb LC7D0
 ;***********************************************************************************************************
 ; The following code handles displaying text on the screen. It works as follows.
 ;