Home » Archimedes archive » Acorn User » AU 1996-Xmas.adf » Features » Arcade/!Popcorn/s/Plotters

Arcade/!Popcorn/s/Plotters

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn User » AU 1996-Xmas.adf » Features
Filename: Arcade/!Popcorn/s/Plotters
Read OK:
File size: 2F08 bytes
Load address: 0000
Exec address: 0000
File contents
 AREA	plotters, CODE ; Not strictly true, but we want the important
		       ; variables kept together with the code so we
		       ; don't have to use long ADRs or LDRs

 GET    Hdr.Macros

 EXPORT Popcorn_ReadScreenDetails, Popcorn_SwapBanks
 EXPORT Popcorn_PlotSprite, Popcorn_PlotBackdrop
 EXPORT Popcorn_SetClipWindow, Popcorn_ClearScreen

 EXPORT plot_window

in_buffer1	& 148,149,11,12,7,4,5,-1
screen_number	& 0 ; 0 or 1 depending on animation frame
screen_start	& 0 ; Base of screen bank to start plotting on
screen_reserve	& 0 ; Base of screen bank being displayed
screen_lastxpix	& 0 ; No. of columns on screen
screen_lastypix & 0 ; No. of rows on screen
screen_size	& 0 ; Size of one screen bank
plot_window
screen_clip_left	& 0
screen_clip_top		& 0
screen_clip_right	& 0
screen_clip_bottom 	& 0

no_shadow	& 0
		DCB "No shadow screen memory found.",0

 ALIGN

Popcorn_ReadScreenDetails
;
; Self-explanatory routine which reads in a few VDU variables and
; stores them internally for the sprite plotter and other display
; routines
;
	STMFD	R13!,{R0-R2,R14}
	MOV	R0,#112
	MOV	R1,#2
	STR	R1,screen_number
	SWI	6 ; OS_Byte
	MOV	R0,#113
	MOV	R1,#1
	SWI	6 ; OS_Byte
	ADR	R0,in_buffer1
	ADR	R1,screen_start
	SWI	&31 ; OS_ReadVduVariables
	LDR	R1,screen_lastxpix
	LDR	R2,screen_lastypix
	STR	R1,screen_clip_right
	STR	R2,screen_clip_bottom
	MOV	R2,#0
	STR	R2,screen_clip_top
	STR	R2,screen_clip_left
	LDR	R0,screen_start
	LDR	R1,screen_reserve
	CMP	R0,R1
	ADREQ	R0,no_shadow
	SWIEQ	&2B ; OS_GenerateError
	LDMFD	R13!,{R0-R2,PC}^

Popcorn_SwapBanks
;
; Another fairly simple routine...
;
	STMFD	R13!,{R0-R2,R14}
	LDR	R0,screen_start
	LDR	R1,screen_reserve
	STR	R1,screen_start
	STR	R0,screen_reserve

	LDR	R1,screen_number
	RSB	R1,R1,#3
	STR	R1,screen_number
	MOV	R0,#112
	SWI	6 ; OS_Byte
	MOV	R0,#113
	SWI	6 ; OS_Byte
	LDMFD	R13!,{R0-R2,PC}^

Popcorn_ClearScreen
;
; Fills the screen memory as quickly as possible with a particular
; byte, specified in R0.  It's fast anyway.
;
	STMFD	R13!,{R0-R12,R14}
	AND	R0,R0,R0,LSL#8
	AND	R0,R0,R0,LSL#16
	MOV	R1,R0
	MOV	R2,R0
	MOV	R3,R0
	MOV	R4,R0
	MOV	R5,R0
	MOV	R6,R0
	MOV	R7,R0
	MOV	R8,R0
	MOV	R9,R0
	MOV	R10,R0
	MOV	R11,R0
	LDR	R12,screen_start
	LDR	R14,screen_size
	SUB	R14,R14,#48
Popcorn_ClearScreen_loop
	STMIA	R12!,{R0-R11} ; Store 48 bytes at a time
	SUBS	R14,R14,#48
	BGT	Popcorn_ClearScreen_loop
	ADD	R14,R14,#48
	TST	R14,#32
	STMNEIA	R12!,{R0-R7}  ; Then carry on in decreasing powers of two
	TST	R14,#16
	STMNEIA	R12!,{R0-R3}
	TST	R4,#8
	STMNEIA	R12!,{R0-R1}
	TST	R4,#4
	STRNE	R0,[R12],#4
	TST	R4,#2
	STRNEB	R0,[R12],#1
	STRNEB	R0,[R12],#1
	TST	R4,#1
	STRNEB	R0,[R12],#1
	LDMFD	R13!,{R0-R12,PC}

Popcorn_PlotBackdrop
;
; Enter with R0 > backdrop data; similar to above routine
;
	STMFD	R13!,{R0-R12,R14}
	LDR	R12,screen_start
	LDR	R14,screen_size
	MOV	R11,R0
	SUBS	R14,R14,#44
Popcorn_PlotBackdrop_loop
	LDMIA	R11!,{R0-R10}
	STMIA	R12!,{R0-R10}
	SUBS	R14,R14,#44
	BGT	Popcorn_PlotBackdrop_loop
	ADD	R14,R14,#44
	TST	R14,#32
	LDMNEIA	R11!,{R0-R7}
	STMNEIA	R12!,{R0-R7}
	TST	R14,#16
	LDMNEIA	R11!,{R0-R3}
	STMNEIA	R12!,{R0-R3}
	TST	R4,#8
	LDMNEIA	R11!,{R0-R1}
	STMEQIA	R12!,{R0-R1}
	TST	R4,#4
	LDRNE	R0,[R11],#4
	STRNE	R0,[R12],#4
	TST	R4,#2
	LDRNEB	R0,[R11],#1
	STRNEB	R0,[R12],#1
	LDRNEB	R0,[R11],#1
	STRNEB	R0,[R12],#1
	TST	R4,#1
	LDRNEB	R0,[R11],#1
	STRNEB	R0,[R12],#1
	LDMFD	R13!,{R0-R12,PC}

Popcorn_SetClipWindow
	STMFD	R13!,{R14}
	STR	R0,screen_clip_left
	STR	R1,screen_clip_top
	STR	R2,screen_clip_right
	STR	R3,screen_clip_bottom
	LDMFD	R13!,{PC}

Popcorn_PlotSprite
;
; Enter with R0 > sprite data, format as described in magazine
;	     R1 = x counting right from 0 (left)
;	     R2 = y counting down from 0 (top)
;
	CMP	R0,#0
	MOVEQ	PC,R14
	STMFD	R13!,{R0-R12,R14}
;
; First thing we need to do is decide if we're totally off
;
	LDR	R3,[R0,#0]	; Width of sprite
	LDR	R4,[R0,#4]	; Height of sprite
	ADD	R3,R3,#1
	ADD	R4,R4,#1
	ADD	R3,R3,R1	; R3 = furthest right pixel to be plotted
	ADD	R4,R4,R2	; R4 = lowest pixel to be plotted
	LDR	R5,screen_clip_bottom
	LDR	R6,screen_clip_top
	LDR	R7,screen_clip_left
	LDR	R8,screen_clip_right
	CMP	R1,R8
	LDMGTFD	R13!,{R0-R12,PC}^	; Off right?
	CMP	R2,R5
	LDMGTFD	R13!,{R0-R12,PC}^	; Off bottom?
	CMP	R3,R7
	LDMLTFD	R13!,{R0-R12,PC}^	; Off left?
	CMP	R4,R6
	LDMLTFD	R13!,{R0-R12,PC}^	; Off top?

	STR	R4,last_y		; Store for later
	STR	R1,first_x		; likewise
;
; Now we know we have a sprite which is at least partially on screen,
; we need to find the first byte to start plotting at on the fisrt
; scan line
;
; Start = screen base address + x position + (y position * line length)
;
	LDR	R3,screen_start
	LDR	R4,screen_lastxpix
	ADD	R4,R4,#1
	MLA	R11,R2,R4,R3
	ADD	R11,R11,R1
; So now we'll keep R11 as our 'plot here' register

; We now need to find out where to start looking for our scan-line data
; which is determined by which image copy we choose, which is
; determined by what alignment we want.  See? :-)
;
	ADD	R10,R0,#8
	AND	R4,R1,#3		; R4 = alignment
	ADD	R10,R10,R4,LSL#2
	LDR	R10,[R10]
	ADD	R10,R10,R0		; R10 > start of scan-line data ptrs
	STR	R10,next_scan_line_ptr
;
; We've now got the 'from' and 'to' addresses, so start plotting lines now
; Quick list of registers to keep hold of : R10 > next scan-line data ptr
;					    R11 > next screen address
;					    R12 > next scan-line data
;
	B	first_scan_line		; Skip bit to increase counters
next_scan_line
	ADD	R2,R2,#1
	LDR	R3,last_y
	CMP	R2,R3			; Check we've not finished
	BEQ	finished_plot
	LDR	R11,next_scan_line_address ; Move R11 to next scan line
first_scan_line				; Registers already set up!
;
; First thing to do is work out where the start of the next scan line
; should be to avoid messy calculations later
;
	LDR	R3,screen_lastxpix
	ADD	R3,R3,#1
	ADD	R3,R3,R11
	STR	R3,next_scan_line_address
;
;
; First thing to check for is y clipping; if we're not on top or bottom,
; there's no point in going any further
;
	LDR	R3,screen_clip_bottom
	CMP	R2,R3
	BGT	finished_plot		; Finished if we're off the bottom
	LDR	R3,screen_clip_top
	CMP	R2,R3
	ADDLT	R10,R10,#4
	BLT	next_scan_line		; Try next line if we're off the top
;
; Right, now we know we have a scan line which is in the plot window
; in the y direction anyway, so we must have something to plot, so get
; the start of the scan line data
;

;
; Fetch the address of the first part of the scan line into R12
; and move R10 along
;
	LDR	R1,first_x		; Reset R1 to start of line
	LDR	R12,[R10],#4
	ADD	R12,R12,R0		; Get scan line ptr into R12
next_scan_line_bit
	LDR	R9,[R12],#4		; Get action code into R9
	MOV	R8,R9,LSR#24		; R8 = action
	BIC	R9,R9,#&FF000000	; R9 = number of bytes
;
; Now take some action on R8, or rather just check if it is zero
;
	CMP	R8,#2
	BGT	uh_oh
	CMP	R8,#0
	BEQ	next_scan_line
; Otherwise work out R5 and carry on
	ADD	R5,R1,R9		; R5 = x position after plot
;
; We have the positions of the first and last bytes of the 'bit', now
; work out whether the 'bit' is fully on-screen, or whether we need
; to do some X clipping
;
	LDR	R3,screen_clip_left
	LDR	R4,screen_clip_right
	CMP	R1,R3
	BLT	clip_left
	CMP	R5,R4
	BGT	clip_right
	B	no_clipping
;
; Relevant registers for X clipping -- pay attention to this
;
; R1  = x co-ordinate to start plotting (could be off screen?)
; R2  = y co-ordinate to start plotting
; R3  = first x pixel in window
; R4  = last x pixel in window
; R5  = x co-ordinate after plot (off screen?)
; R8  = 'type' part of type word (i.e. tt)
; R9  = number of bytes (i.e. dddd)
; R11 = screen address to start
; R12 = start address of sprite data
;
clip_left
	CMP	R8,#2
	BNE	clip_left_bit_on
	ADD	R11,R11,R9
	MOV	R1,R5
	B	next_scan_line_bit	; Deal with masks by just shifting
					; the relevant pointers on
clip_left_bit_on
	CMP	R5,R3
	BGE	clip_left_not_completely_off
	AND	R7,R11,#3
	ADD	R12,R12,R7		; Push R12 along according to align
	ADD	R12,R12,R9
	ADD	R11,R11,R9
	MOV	R1,R5
	B	align_r12_no_restore
clip_left_not_completely_off
	AND	R7,R11,#3
	ADD	R12,R12,R7		; Push R12 along according to align
	SUB	R6,R3,R1		; R6 = no. of pixels off left
	ADD	R11,R11,R6
	ADD	R12,R12,R6
	MOV	R1,R5
	SUB	R9,R9,R6		; Adjust start / no. of pixels
	CMP	R5,R4			; Check for clip right as well
	BLE	start_plot_bit
	ADD	R4,R4,#1		;
	SUB	R6,R5,R4		; Code copied from below
	STR	R6,compensate_right	;
	SUB	R9,R9,R6		;
	B	start_plot_bit		;

clip_right
	CMP	R8,#2
	BEQ	next_scan_line		; Mask off right -> next line
	ADD	R4,R4,#1		; Arse
	SUB	R6,R5,R4		; R6 = no. of pixels off right
	STR	R6,compensate_right	; Compensate after plot
	SUB	R9,R9,R6		; Clip pixels off right
	MOV	R1,R5
	AND	R3,R11,#3
	ADD	R12,R12,R3
	B	start_plot_bit

no_clipping
	ADD	R1,R1,R9		; Adjust X
	CMP	R8,#2
	ADDEQ	R11,R11,R9
	BEQ	next_scan_line_bit	; Skip screen memory if it's a mask
	AND	R3,R11,#3		; Get alignment of screen address
	ADD	R12,R12,R3		; Adjust start of data
;
; Right, here is where we can start plotting!
;   R12 > sprite data (aligned, so watch for zeroes at start)
;   R11 > screen memory to start (adjusted for clipping)
;   R9  = number of bytes to plot
;
start_plot_bit
	STMFD	R13!,{R0-R7}		; Keep scratch registers
					; 'cos we're going to overwrite them
					; with multiple loads/stores
;
; Plot 0-3 bytes so we start on a word boundary
;
	CMP	R9,#0
	BLE	align_r12
	TST	R11,#1
	BEQ	no_align_0
	LDRB	R0,[R12],#1
	STRB	R0,[R11],#1
	SUBS	R9,R9,#1
	BEQ	align_r12
no_align_0
	TST	R11,#2
	BEQ	no_align_1
	LDRB	R0,[R12],#1
	STRB	R0,[R11],#1
	SUBS	R9,R9,#1
	BEQ	align_r12
	LDRB	R0,[R12],#1
	STRB	R0,[R11],#1
	SUBS	R9,R9,#1
	BEQ	align_r12
no_align_1

;
; Now we're on a word boundary, we can start plotting big chunks with
; LDR and LDM instructions
;
	TST	R9,#2_100
	BEQ	no_bit_2
	LDR	R0,[R12],#4
	STR	R0,[R11],#4
	BICS	R0,R9,#2_111
	BEQ	no_bit_8
no_bit_2
	TST	R9,#2_1000
	BEQ	no_bit_3
	LDMIA	R12!,{R0-R1}
	STMIA	R11!,{R0-R1}
no_bit_3
	TST	R9,#2_10000
	BEQ	no_bit_4
	LDMIA	R12!,{R0-R3}
	STMIA	R11!,{R0-R3}
no_bit_4
	TST	R9,#2_100000
	BEQ	no_bit_5
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
no_bit_5
	TST	R9,#2_1000000
	BEQ	no_bit_6
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
no_bit_6
	TST	R9,#2_10000000
	BEQ	no_bit_7
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
no_bit_7
	TST	R9,#2_100000000
	BEQ	no_bit_8
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
	LDMIA	R12!,{R0-R7}
	STMIA	R11!,{R0-R7}
no_bit_8
;
; Now we should have plotted all but the last 0-3 bytes
;
	TST	R9,#2_1
	BEQ	no_bit_0
	LDRB	R0,[R12],#1
	STRB	R0,[R11],#1
no_bit_0
	TST	R9,#2_10
	BEQ	no_bit_1
	LDRB	R0,[R12],#1
	STRB	R0,[R11],#1
	LDRB	R0,[R12],#1
	STRB	R0,[R11],#1
no_bit_1
;
; Now we need to align R12 so that it points to the next 'type' word,
; since it could be straggling at a non word-aligned position.
;
align_r12
	LDMFD	R13!,{R0-R7}		; Restore scratch registers
align_r12_no_restore
	LDR	R3,compensate_right
	ADD	R12,R12,R3
	MOV	R3,#0
	STR	R3,compensate_right
	ADD	R12,R12,#3
	BIC	R12,R12,#3
no_align
	B	next_scan_line_bit
finished_plot
	LDMFD	R13!,{R0-R12,PC}^
;
; This should never happen :-)
;
uh_oh
	ADR	R0,error
	SWI	&2B ; OS_GenerateError

error	& 0
	DCB "Type word out of range (0-2)",0
	ALIGN

last_y			& 0
first_x			& 0
next_scan_line_address	& 0
next_scan_line_ptr	& 0
compensate_right	& 0

 END
00000000  20 41 52 45 41 09 70 6c  6f 74 74 65 72 73 2c 20  | AREA.plotters, |
00000010  43 4f 44 45 20 3b 20 4e  6f 74 20 73 74 72 69 63  |CODE ; Not stric|
00000020  74 6c 79 20 74 72 75 65  2c 20 62 75 74 20 77 65  |tly true, but we|
00000030  20 77 61 6e 74 20 74 68  65 20 69 6d 70 6f 72 74  | want the import|
00000040  61 6e 74 0d 0a 09 09 20  20 20 20 20 20 20 3b 20  |ant....       ; |
00000050  76 61 72 69 61 62 6c 65  73 20 6b 65 70 74 20 74  |variables kept t|
00000060  6f 67 65 74 68 65 72 20  77 69 74 68 20 74 68 65  |ogether with the|
00000070  20 63 6f 64 65 20 73 6f  20 77 65 0d 0a 09 09 20  | code so we.... |
00000080  20 20 20 20 20 20 3b 20  64 6f 6e 27 74 20 68 61  |      ; don't ha|
00000090  76 65 20 74 6f 20 75 73  65 20 6c 6f 6e 67 20 41  |ve to use long A|
000000a0  44 52 73 20 6f 72 20 4c  44 52 73 0d 0a 0d 0a 20  |DRs or LDRs.... |
000000b0  47 45 54 20 20 20 20 48  64 72 2e 4d 61 63 72 6f  |GET    Hdr.Macro|
000000c0  73 0d 0a 0d 0a 20 45 58  50 4f 52 54 20 50 6f 70  |s.... EXPORT Pop|
000000d0  63 6f 72 6e 5f 52 65 61  64 53 63 72 65 65 6e 44  |corn_ReadScreenD|
000000e0  65 74 61 69 6c 73 2c 20  50 6f 70 63 6f 72 6e 5f  |etails, Popcorn_|
000000f0  53 77 61 70 42 61 6e 6b  73 0d 0a 20 45 58 50 4f  |SwapBanks.. EXPO|
00000100  52 54 20 50 6f 70 63 6f  72 6e 5f 50 6c 6f 74 53  |RT Popcorn_PlotS|
00000110  70 72 69 74 65 2c 20 50  6f 70 63 6f 72 6e 5f 50  |prite, Popcorn_P|
00000120  6c 6f 74 42 61 63 6b 64  72 6f 70 0d 0a 20 45 58  |lotBackdrop.. EX|
00000130  50 4f 52 54 20 50 6f 70  63 6f 72 6e 5f 53 65 74  |PORT Popcorn_Set|
00000140  43 6c 69 70 57 69 6e 64  6f 77 2c 20 50 6f 70 63  |ClipWindow, Popc|
00000150  6f 72 6e 5f 43 6c 65 61  72 53 63 72 65 65 6e 0d  |orn_ClearScreen.|
00000160  0a 0d 0a 20 45 58 50 4f  52 54 20 70 6c 6f 74 5f  |... EXPORT plot_|
00000170  77 69 6e 64 6f 77 0d 0a  0d 0a 69 6e 5f 62 75 66  |window....in_buf|
00000180  66 65 72 31 09 26 20 31  34 38 2c 31 34 39 2c 31  |fer1.& 148,149,1|
00000190  31 2c 31 32 2c 37 2c 34  2c 35 2c 2d 31 0d 0a 73  |1,12,7,4,5,-1..s|
000001a0  63 72 65 65 6e 5f 6e 75  6d 62 65 72 09 26 20 30  |creen_number.& 0|
000001b0  20 3b 20 30 20 6f 72 20  31 20 64 65 70 65 6e 64  | ; 0 or 1 depend|
000001c0  69 6e 67 20 6f 6e 20 61  6e 69 6d 61 74 69 6f 6e  |ing on animation|
000001d0  20 66 72 61 6d 65 0d 0a  73 63 72 65 65 6e 5f 73  | frame..screen_s|
000001e0  74 61 72 74 09 26 20 30  20 3b 20 42 61 73 65 20  |tart.& 0 ; Base |
000001f0  6f 66 20 73 63 72 65 65  6e 20 62 61 6e 6b 20 74  |of screen bank t|
00000200  6f 20 73 74 61 72 74 20  70 6c 6f 74 74 69 6e 67  |o start plotting|
00000210  20 6f 6e 0d 0a 73 63 72  65 65 6e 5f 72 65 73 65  | on..screen_rese|
00000220  72 76 65 09 26 20 30 20  3b 20 42 61 73 65 20 6f  |rve.& 0 ; Base o|
00000230  66 20 73 63 72 65 65 6e  20 62 61 6e 6b 20 62 65  |f screen bank be|
00000240  69 6e 67 20 64 69 73 70  6c 61 79 65 64 0d 0a 73  |ing displayed..s|
00000250  63 72 65 65 6e 5f 6c 61  73 74 78 70 69 78 09 26  |creen_lastxpix.&|
00000260  20 30 20 3b 20 4e 6f 2e  20 6f 66 20 63 6f 6c 75  | 0 ; No. of colu|
00000270  6d 6e 73 20 6f 6e 20 73  63 72 65 65 6e 0d 0a 73  |mns on screen..s|
00000280  63 72 65 65 6e 5f 6c 61  73 74 79 70 69 78 20 26  |creen_lastypix &|
00000290  20 30 20 3b 20 4e 6f 2e  20 6f 66 20 72 6f 77 73  | 0 ; No. of rows|
000002a0  20 6f 6e 20 73 63 72 65  65 6e 0d 0a 73 63 72 65  | on screen..scre|
000002b0  65 6e 5f 73 69 7a 65 09  26 20 30 20 3b 20 53 69  |en_size.& 0 ; Si|
000002c0  7a 65 20 6f 66 20 6f 6e  65 20 73 63 72 65 65 6e  |ze of one screen|
000002d0  20 62 61 6e 6b 0d 0a 70  6c 6f 74 5f 77 69 6e 64  | bank..plot_wind|
000002e0  6f 77 0d 0a 73 63 72 65  65 6e 5f 63 6c 69 70 5f  |ow..screen_clip_|
000002f0  6c 65 66 74 09 26 20 30  0d 0a 73 63 72 65 65 6e  |left.& 0..screen|
00000300  5f 63 6c 69 70 5f 74 6f  70 09 09 26 20 30 0d 0a  |_clip_top..& 0..|
00000310  73 63 72 65 65 6e 5f 63  6c 69 70 5f 72 69 67 68  |screen_clip_righ|
00000320  74 09 26 20 30 0d 0a 73  63 72 65 65 6e 5f 63 6c  |t.& 0..screen_cl|
00000330  69 70 5f 62 6f 74 74 6f  6d 20 09 26 20 30 0d 0a  |ip_bottom .& 0..|
00000340  0d 0a 6e 6f 5f 73 68 61  64 6f 77 09 26 20 30 0d  |..no_shadow.& 0.|
00000350  0a 09 09 44 43 42 20 22  4e 6f 20 73 68 61 64 6f  |...DCB "No shado|
00000360  77 20 73 63 72 65 65 6e  20 6d 65 6d 6f 72 79 20  |w screen memory |
00000370  66 6f 75 6e 64 2e 22 2c  30 0d 0a 0d 0a 20 41 4c  |found.",0.... AL|
00000380  49 47 4e 0d 0a 0d 0a 50  6f 70 63 6f 72 6e 5f 52  |IGN....Popcorn_R|
00000390  65 61 64 53 63 72 65 65  6e 44 65 74 61 69 6c 73  |eadScreenDetails|
000003a0  0d 0a 3b 0d 0a 3b 20 53  65 6c 66 2d 65 78 70 6c  |..;..; Self-expl|
000003b0  61 6e 61 74 6f 72 79 20  72 6f 75 74 69 6e 65 20  |anatory routine |
000003c0  77 68 69 63 68 20 72 65  61 64 73 20 69 6e 20 61  |which reads in a|
000003d0  20 66 65 77 20 56 44 55  20 76 61 72 69 61 62 6c  | few VDU variabl|
000003e0  65 73 20 61 6e 64 0d 0a  3b 20 73 74 6f 72 65 73  |es and..; stores|
000003f0  20 74 68 65 6d 20 69 6e  74 65 72 6e 61 6c 6c 79  | them internally|
00000400  20 66 6f 72 20 74 68 65  20 73 70 72 69 74 65 20  | for the sprite |
00000410  70 6c 6f 74 74 65 72 20  61 6e 64 20 6f 74 68 65  |plotter and othe|
00000420  72 20 64 69 73 70 6c 61  79 0d 0a 3b 20 72 6f 75  |r display..; rou|
00000430  74 69 6e 65 73 0d 0a 3b  0d 0a 09 53 54 4d 46 44  |tines..;...STMFD|
00000440  09 52 31 33 21 2c 7b 52  30 2d 52 32 2c 52 31 34  |.R13!,{R0-R2,R14|
00000450  7d 0d 0a 09 4d 4f 56 09  52 30 2c 23 31 31 32 0d  |}...MOV.R0,#112.|
00000460  0a 09 4d 4f 56 09 52 31  2c 23 32 0d 0a 09 53 54  |..MOV.R1,#2...ST|
00000470  52 09 52 31 2c 73 63 72  65 65 6e 5f 6e 75 6d 62  |R.R1,screen_numb|
00000480  65 72 0d 0a 09 53 57 49  09 36 20 3b 20 4f 53 5f  |er...SWI.6 ; OS_|
00000490  42 79 74 65 0d 0a 09 4d  4f 56 09 52 30 2c 23 31  |Byte...MOV.R0,#1|
000004a0  31 33 0d 0a 09 4d 4f 56  09 52 31 2c 23 31 0d 0a  |13...MOV.R1,#1..|
000004b0  09 53 57 49 09 36 20 3b  20 4f 53 5f 42 79 74 65  |.SWI.6 ; OS_Byte|
000004c0  0d 0a 09 41 44 52 09 52  30 2c 69 6e 5f 62 75 66  |...ADR.R0,in_buf|
000004d0  66 65 72 31 0d 0a 09 41  44 52 09 52 31 2c 73 63  |fer1...ADR.R1,sc|
000004e0  72 65 65 6e 5f 73 74 61  72 74 0d 0a 09 53 57 49  |reen_start...SWI|
000004f0  09 26 33 31 20 3b 20 4f  53 5f 52 65 61 64 56 64  |.&31 ; OS_ReadVd|
00000500  75 56 61 72 69 61 62 6c  65 73 0d 0a 09 4c 44 52  |uVariables...LDR|
00000510  09 52 31 2c 73 63 72 65  65 6e 5f 6c 61 73 74 78  |.R1,screen_lastx|
00000520  70 69 78 0d 0a 09 4c 44  52 09 52 32 2c 73 63 72  |pix...LDR.R2,scr|
00000530  65 65 6e 5f 6c 61 73 74  79 70 69 78 0d 0a 09 53  |een_lastypix...S|
00000540  54 52 09 52 31 2c 73 63  72 65 65 6e 5f 63 6c 69  |TR.R1,screen_cli|
00000550  70 5f 72 69 67 68 74 0d  0a 09 53 54 52 09 52 32  |p_right...STR.R2|
00000560  2c 73 63 72 65 65 6e 5f  63 6c 69 70 5f 62 6f 74  |,screen_clip_bot|
00000570  74 6f 6d 0d 0a 09 4d 4f  56 09 52 32 2c 23 30 0d  |tom...MOV.R2,#0.|
00000580  0a 09 53 54 52 09 52 32  2c 73 63 72 65 65 6e 5f  |..STR.R2,screen_|
00000590  63 6c 69 70 5f 74 6f 70  0d 0a 09 53 54 52 09 52  |clip_top...STR.R|
000005a0  32 2c 73 63 72 65 65 6e  5f 63 6c 69 70 5f 6c 65  |2,screen_clip_le|
000005b0  66 74 0d 0a 09 4c 44 52  09 52 30 2c 73 63 72 65  |ft...LDR.R0,scre|
000005c0  65 6e 5f 73 74 61 72 74  0d 0a 09 4c 44 52 09 52  |en_start...LDR.R|
000005d0  31 2c 73 63 72 65 65 6e  5f 72 65 73 65 72 76 65  |1,screen_reserve|
000005e0  0d 0a 09 43 4d 50 09 52  30 2c 52 31 0d 0a 09 41  |...CMP.R0,R1...A|
000005f0  44 52 45 51 09 52 30 2c  6e 6f 5f 73 68 61 64 6f  |DREQ.R0,no_shado|
00000600  77 0d 0a 09 53 57 49 45  51 09 26 32 42 20 3b 20  |w...SWIEQ.&2B ; |
00000610  4f 53 5f 47 65 6e 65 72  61 74 65 45 72 72 6f 72  |OS_GenerateError|
00000620  0d 0a 09 4c 44 4d 46 44  09 52 31 33 21 2c 7b 52  |...LDMFD.R13!,{R|
00000630  30 2d 52 32 2c 50 43 7d  5e 0d 0a 0d 0a 50 6f 70  |0-R2,PC}^....Pop|
00000640  63 6f 72 6e 5f 53 77 61  70 42 61 6e 6b 73 0d 0a  |corn_SwapBanks..|
00000650  3b 0d 0a 3b 20 41 6e 6f  74 68 65 72 20 66 61 69  |;..; Another fai|
00000660  72 6c 79 20 73 69 6d 70  6c 65 20 72 6f 75 74 69  |rly simple routi|
00000670  6e 65 2e 2e 2e 0d 0a 3b  0d 0a 09 53 54 4d 46 44  |ne.....;...STMFD|
00000680  09 52 31 33 21 2c 7b 52  30 2d 52 32 2c 52 31 34  |.R13!,{R0-R2,R14|
00000690  7d 0d 0a 09 4c 44 52 09  52 30 2c 73 63 72 65 65  |}...LDR.R0,scree|
000006a0  6e 5f 73 74 61 72 74 0d  0a 09 4c 44 52 09 52 31  |n_start...LDR.R1|
000006b0  2c 73 63 72 65 65 6e 5f  72 65 73 65 72 76 65 0d  |,screen_reserve.|
000006c0  0a 09 53 54 52 09 52 31  2c 73 63 72 65 65 6e 5f  |..STR.R1,screen_|
000006d0  73 74 61 72 74 0d 0a 09  53 54 52 09 52 30 2c 73  |start...STR.R0,s|
000006e0  63 72 65 65 6e 5f 72 65  73 65 72 76 65 0d 0a 0d  |creen_reserve...|
000006f0  0a 09 4c 44 52 09 52 31  2c 73 63 72 65 65 6e 5f  |..LDR.R1,screen_|
00000700  6e 75 6d 62 65 72 0d 0a  09 52 53 42 09 52 31 2c  |number...RSB.R1,|
00000710  52 31 2c 23 33 0d 0a 09  53 54 52 09 52 31 2c 73  |R1,#3...STR.R1,s|
00000720  63 72 65 65 6e 5f 6e 75  6d 62 65 72 0d 0a 09 4d  |creen_number...M|
00000730  4f 56 09 52 30 2c 23 31  31 32 0d 0a 09 53 57 49  |OV.R0,#112...SWI|
00000740  09 36 20 3b 20 4f 53 5f  42 79 74 65 0d 0a 09 4d  |.6 ; OS_Byte...M|
00000750  4f 56 09 52 30 2c 23 31  31 33 0d 0a 09 53 57 49  |OV.R0,#113...SWI|
00000760  09 36 20 3b 20 4f 53 5f  42 79 74 65 0d 0a 09 4c  |.6 ; OS_Byte...L|
00000770  44 4d 46 44 09 52 31 33  21 2c 7b 52 30 2d 52 32  |DMFD.R13!,{R0-R2|
00000780  2c 50 43 7d 5e 0d 0a 0d  0a 50 6f 70 63 6f 72 6e  |,PC}^....Popcorn|
00000790  5f 43 6c 65 61 72 53 63  72 65 65 6e 0d 0a 3b 0d  |_ClearScreen..;.|
000007a0  0a 3b 20 46 69 6c 6c 73  20 74 68 65 20 73 63 72  |.; Fills the scr|
000007b0  65 65 6e 20 6d 65 6d 6f  72 79 20 61 73 20 71 75  |een memory as qu|
000007c0  69 63 6b 6c 79 20 61 73  20 70 6f 73 73 69 62 6c  |ickly as possibl|
000007d0  65 20 77 69 74 68 20 61  20 70 61 72 74 69 63 75  |e with a particu|
000007e0  6c 61 72 0d 0a 3b 20 62  79 74 65 2c 20 73 70 65  |lar..; byte, spe|
000007f0  63 69 66 69 65 64 20 69  6e 20 52 30 2e 20 20 49  |cified in R0.  I|
00000800  74 27 73 20 66 61 73 74  20 61 6e 79 77 61 79 2e  |t's fast anyway.|
00000810  0d 0a 3b 0d 0a 09 53 54  4d 46 44 09 52 31 33 21  |..;...STMFD.R13!|
00000820  2c 7b 52 30 2d 52 31 32  2c 52 31 34 7d 0d 0a 09  |,{R0-R12,R14}...|
00000830  41 4e 44 09 52 30 2c 52  30 2c 52 30 2c 4c 53 4c  |AND.R0,R0,R0,LSL|
00000840  23 38 0d 0a 09 41 4e 44  09 52 30 2c 52 30 2c 52  |#8...AND.R0,R0,R|
00000850  30 2c 4c 53 4c 23 31 36  0d 0a 09 4d 4f 56 09 52  |0,LSL#16...MOV.R|
00000860  31 2c 52 30 0d 0a 09 4d  4f 56 09 52 32 2c 52 30  |1,R0...MOV.R2,R0|
00000870  0d 0a 09 4d 4f 56 09 52  33 2c 52 30 0d 0a 09 4d  |...MOV.R3,R0...M|
00000880  4f 56 09 52 34 2c 52 30  0d 0a 09 4d 4f 56 09 52  |OV.R4,R0...MOV.R|
00000890  35 2c 52 30 0d 0a 09 4d  4f 56 09 52 36 2c 52 30  |5,R0...MOV.R6,R0|
000008a0  0d 0a 09 4d 4f 56 09 52  37 2c 52 30 0d 0a 09 4d  |...MOV.R7,R0...M|
000008b0  4f 56 09 52 38 2c 52 30  0d 0a 09 4d 4f 56 09 52  |OV.R8,R0...MOV.R|
000008c0  39 2c 52 30 0d 0a 09 4d  4f 56 09 52 31 30 2c 52  |9,R0...MOV.R10,R|
000008d0  30 0d 0a 09 4d 4f 56 09  52 31 31 2c 52 30 0d 0a  |0...MOV.R11,R0..|
000008e0  09 4c 44 52 09 52 31 32  2c 73 63 72 65 65 6e 5f  |.LDR.R12,screen_|
000008f0  73 74 61 72 74 0d 0a 09  4c 44 52 09 52 31 34 2c  |start...LDR.R14,|
00000900  73 63 72 65 65 6e 5f 73  69 7a 65 0d 0a 09 53 55  |screen_size...SU|
00000910  42 09 52 31 34 2c 52 31  34 2c 23 34 38 0d 0a 50  |B.R14,R14,#48..P|
00000920  6f 70 63 6f 72 6e 5f 43  6c 65 61 72 53 63 72 65  |opcorn_ClearScre|
00000930  65 6e 5f 6c 6f 6f 70 0d  0a 09 53 54 4d 49 41 09  |en_loop...STMIA.|
00000940  52 31 32 21 2c 7b 52 30  2d 52 31 31 7d 20 3b 20  |R12!,{R0-R11} ; |
00000950  53 74 6f 72 65 20 34 38  20 62 79 74 65 73 20 61  |Store 48 bytes a|
00000960  74 20 61 20 74 69 6d 65  0d 0a 09 53 55 42 53 09  |t a time...SUBS.|
00000970  52 31 34 2c 52 31 34 2c  23 34 38 0d 0a 09 42 47  |R14,R14,#48...BG|
00000980  54 09 50 6f 70 63 6f 72  6e 5f 43 6c 65 61 72 53  |T.Popcorn_ClearS|
00000990  63 72 65 65 6e 5f 6c 6f  6f 70 0d 0a 09 41 44 44  |creen_loop...ADD|
000009a0  09 52 31 34 2c 52 31 34  2c 23 34 38 0d 0a 09 54  |.R14,R14,#48...T|
000009b0  53 54 09 52 31 34 2c 23  33 32 0d 0a 09 53 54 4d  |ST.R14,#32...STM|
000009c0  4e 45 49 41 09 52 31 32  21 2c 7b 52 30 2d 52 37  |NEIA.R12!,{R0-R7|
000009d0  7d 20 20 3b 20 54 68 65  6e 20 63 61 72 72 79 20  |}  ; Then carry |
000009e0  6f 6e 20 69 6e 20 64 65  63 72 65 61 73 69 6e 67  |on in decreasing|
000009f0  20 70 6f 77 65 72 73 20  6f 66 20 74 77 6f 0d 0a  | powers of two..|
00000a00  09 54 53 54 09 52 31 34  2c 23 31 36 0d 0a 09 53  |.TST.R14,#16...S|
00000a10  54 4d 4e 45 49 41 09 52  31 32 21 2c 7b 52 30 2d  |TMNEIA.R12!,{R0-|
00000a20  52 33 7d 0d 0a 09 54 53  54 09 52 34 2c 23 38 0d  |R3}...TST.R4,#8.|
00000a30  0a 09 53 54 4d 4e 45 49  41 09 52 31 32 21 2c 7b  |..STMNEIA.R12!,{|
00000a40  52 30 2d 52 31 7d 0d 0a  09 54 53 54 09 52 34 2c  |R0-R1}...TST.R4,|
00000a50  23 34 0d 0a 09 53 54 52  4e 45 09 52 30 2c 5b 52  |#4...STRNE.R0,[R|
00000a60  31 32 5d 2c 23 34 0d 0a  09 54 53 54 09 52 34 2c  |12],#4...TST.R4,|
00000a70  23 32 0d 0a 09 53 54 52  4e 45 42 09 52 30 2c 5b  |#2...STRNEB.R0,[|
00000a80  52 31 32 5d 2c 23 31 0d  0a 09 53 54 52 4e 45 42  |R12],#1...STRNEB|
00000a90  09 52 30 2c 5b 52 31 32  5d 2c 23 31 0d 0a 09 54  |.R0,[R12],#1...T|
00000aa0  53 54 09 52 34 2c 23 31  0d 0a 09 53 54 52 4e 45  |ST.R4,#1...STRNE|
00000ab0  42 09 52 30 2c 5b 52 31  32 5d 2c 23 31 0d 0a 09  |B.R0,[R12],#1...|
00000ac0  4c 44 4d 46 44 09 52 31  33 21 2c 7b 52 30 2d 52  |LDMFD.R13!,{R0-R|
00000ad0  31 32 2c 50 43 7d 0d 0a  0d 0a 50 6f 70 63 6f 72  |12,PC}....Popcor|
00000ae0  6e 5f 50 6c 6f 74 42 61  63 6b 64 72 6f 70 0d 0a  |n_PlotBackdrop..|
00000af0  3b 0d 0a 3b 20 45 6e 74  65 72 20 77 69 74 68 20  |;..; Enter with |
00000b00  52 30 20 3e 20 62 61 63  6b 64 72 6f 70 20 64 61  |R0 > backdrop da|
00000b10  74 61 3b 20 73 69 6d 69  6c 61 72 20 74 6f 20 61  |ta; similar to a|
00000b20  62 6f 76 65 20 72 6f 75  74 69 6e 65 0d 0a 3b 0d  |bove routine..;.|
00000b30  0a 09 53 54 4d 46 44 09  52 31 33 21 2c 7b 52 30  |..STMFD.R13!,{R0|
00000b40  2d 52 31 32 2c 52 31 34  7d 0d 0a 09 4c 44 52 09  |-R12,R14}...LDR.|
00000b50  52 31 32 2c 73 63 72 65  65 6e 5f 73 74 61 72 74  |R12,screen_start|
00000b60  0d 0a 09 4c 44 52 09 52  31 34 2c 73 63 72 65 65  |...LDR.R14,scree|
00000b70  6e 5f 73 69 7a 65 0d 0a  09 4d 4f 56 09 52 31 31  |n_size...MOV.R11|
00000b80  2c 52 30 0d 0a 09 53 55  42 53 09 52 31 34 2c 52  |,R0...SUBS.R14,R|
00000b90  31 34 2c 23 34 34 0d 0a  50 6f 70 63 6f 72 6e 5f  |14,#44..Popcorn_|
00000ba0  50 6c 6f 74 42 61 63 6b  64 72 6f 70 5f 6c 6f 6f  |PlotBackdrop_loo|
00000bb0  70 0d 0a 09 4c 44 4d 49  41 09 52 31 31 21 2c 7b  |p...LDMIA.R11!,{|
00000bc0  52 30 2d 52 31 30 7d 0d  0a 09 53 54 4d 49 41 09  |R0-R10}...STMIA.|
00000bd0  52 31 32 21 2c 7b 52 30  2d 52 31 30 7d 0d 0a 09  |R12!,{R0-R10}...|
00000be0  53 55 42 53 09 52 31 34  2c 52 31 34 2c 23 34 34  |SUBS.R14,R14,#44|
00000bf0  0d 0a 09 42 47 54 09 50  6f 70 63 6f 72 6e 5f 50  |...BGT.Popcorn_P|
00000c00  6c 6f 74 42 61 63 6b 64  72 6f 70 5f 6c 6f 6f 70  |lotBackdrop_loop|
00000c10  0d 0a 09 41 44 44 09 52  31 34 2c 52 31 34 2c 23  |...ADD.R14,R14,#|
00000c20  34 34 0d 0a 09 54 53 54  09 52 31 34 2c 23 33 32  |44...TST.R14,#32|
00000c30  0d 0a 09 4c 44 4d 4e 45  49 41 09 52 31 31 21 2c  |...LDMNEIA.R11!,|
00000c40  7b 52 30 2d 52 37 7d 0d  0a 09 53 54 4d 4e 45 49  |{R0-R7}...STMNEI|
00000c50  41 09 52 31 32 21 2c 7b  52 30 2d 52 37 7d 0d 0a  |A.R12!,{R0-R7}..|
00000c60  09 54 53 54 09 52 31 34  2c 23 31 36 0d 0a 09 4c  |.TST.R14,#16...L|
00000c70  44 4d 4e 45 49 41 09 52  31 31 21 2c 7b 52 30 2d  |DMNEIA.R11!,{R0-|
00000c80  52 33 7d 0d 0a 09 53 54  4d 4e 45 49 41 09 52 31  |R3}...STMNEIA.R1|
00000c90  32 21 2c 7b 52 30 2d 52  33 7d 0d 0a 09 54 53 54  |2!,{R0-R3}...TST|
00000ca0  09 52 34 2c 23 38 0d 0a  09 4c 44 4d 4e 45 49 41  |.R4,#8...LDMNEIA|
00000cb0  09 52 31 31 21 2c 7b 52  30 2d 52 31 7d 0d 0a 09  |.R11!,{R0-R1}...|
00000cc0  53 54 4d 45 51 49 41 09  52 31 32 21 2c 7b 52 30  |STMEQIA.R12!,{R0|
00000cd0  2d 52 31 7d 0d 0a 09 54  53 54 09 52 34 2c 23 34  |-R1}...TST.R4,#4|
00000ce0  0d 0a 09 4c 44 52 4e 45  09 52 30 2c 5b 52 31 31  |...LDRNE.R0,[R11|
00000cf0  5d 2c 23 34 0d 0a 09 53  54 52 4e 45 09 52 30 2c  |],#4...STRNE.R0,|
00000d00  5b 52 31 32 5d 2c 23 34  0d 0a 09 54 53 54 09 52  |[R12],#4...TST.R|
00000d10  34 2c 23 32 0d 0a 09 4c  44 52 4e 45 42 09 52 30  |4,#2...LDRNEB.R0|
00000d20  2c 5b 52 31 31 5d 2c 23  31 0d 0a 09 53 54 52 4e  |,[R11],#1...STRN|
00000d30  45 42 09 52 30 2c 5b 52  31 32 5d 2c 23 31 0d 0a  |EB.R0,[R12],#1..|
00000d40  09 4c 44 52 4e 45 42 09  52 30 2c 5b 52 31 31 5d  |.LDRNEB.R0,[R11]|
00000d50  2c 23 31 0d 0a 09 53 54  52 4e 45 42 09 52 30 2c  |,#1...STRNEB.R0,|
00000d60  5b 52 31 32 5d 2c 23 31  0d 0a 09 54 53 54 09 52  |[R12],#1...TST.R|
00000d70  34 2c 23 31 0d 0a 09 4c  44 52 4e 45 42 09 52 30  |4,#1...LDRNEB.R0|
00000d80  2c 5b 52 31 31 5d 2c 23  31 0d 0a 09 53 54 52 4e  |,[R11],#1...STRN|
00000d90  45 42 09 52 30 2c 5b 52  31 32 5d 2c 23 31 0d 0a  |EB.R0,[R12],#1..|
00000da0  09 4c 44 4d 46 44 09 52  31 33 21 2c 7b 52 30 2d  |.LDMFD.R13!,{R0-|
00000db0  52 31 32 2c 50 43 7d 0d  0a 0d 0a 50 6f 70 63 6f  |R12,PC}....Popco|
00000dc0  72 6e 5f 53 65 74 43 6c  69 70 57 69 6e 64 6f 77  |rn_SetClipWindow|
00000dd0  0d 0a 09 53 54 4d 46 44  09 52 31 33 21 2c 7b 52  |...STMFD.R13!,{R|
00000de0  31 34 7d 0d 0a 09 53 54  52 09 52 30 2c 73 63 72  |14}...STR.R0,scr|
00000df0  65 65 6e 5f 63 6c 69 70  5f 6c 65 66 74 0d 0a 09  |een_clip_left...|
00000e00  53 54 52 09 52 31 2c 73  63 72 65 65 6e 5f 63 6c  |STR.R1,screen_cl|
00000e10  69 70 5f 74 6f 70 0d 0a  09 53 54 52 09 52 32 2c  |ip_top...STR.R2,|
00000e20  73 63 72 65 65 6e 5f 63  6c 69 70 5f 72 69 67 68  |screen_clip_righ|
00000e30  74 0d 0a 09 53 54 52 09  52 33 2c 73 63 72 65 65  |t...STR.R3,scree|
00000e40  6e 5f 63 6c 69 70 5f 62  6f 74 74 6f 6d 0d 0a 09  |n_clip_bottom...|
00000e50  4c 44 4d 46 44 09 52 31  33 21 2c 7b 50 43 7d 0d  |LDMFD.R13!,{PC}.|
00000e60  0a 0d 0a 50 6f 70 63 6f  72 6e 5f 50 6c 6f 74 53  |...Popcorn_PlotS|
00000e70  70 72 69 74 65 0d 0a 3b  0d 0a 3b 20 45 6e 74 65  |prite..;..; Ente|
00000e80  72 20 77 69 74 68 20 52  30 20 3e 20 73 70 72 69  |r with R0 > spri|
00000e90  74 65 20 64 61 74 61 2c  20 66 6f 72 6d 61 74 20  |te data, format |
00000ea0  61 73 20 64 65 73 63 72  69 62 65 64 20 69 6e 20  |as described in |
00000eb0  6d 61 67 61 7a 69 6e 65  0d 0a 3b 09 20 20 20 20  |magazine..;.    |
00000ec0  20 52 31 20 3d 20 78 20  63 6f 75 6e 74 69 6e 67  | R1 = x counting|
00000ed0  20 72 69 67 68 74 20 66  72 6f 6d 20 30 20 28 6c  | right from 0 (l|
00000ee0  65 66 74 29 0d 0a 3b 09  20 20 20 20 20 52 32 20  |eft)..;.     R2 |
00000ef0  3d 20 79 20 63 6f 75 6e  74 69 6e 67 20 64 6f 77  |= y counting dow|
00000f00  6e 20 66 72 6f 6d 20 30  20 28 74 6f 70 29 0d 0a  |n from 0 (top)..|
00000f10  3b 0d 0a 09 43 4d 50 09  52 30 2c 23 30 0d 0a 09  |;...CMP.R0,#0...|
00000f20  4d 4f 56 45 51 09 50 43  2c 52 31 34 0d 0a 09 53  |MOVEQ.PC,R14...S|
00000f30  54 4d 46 44 09 52 31 33  21 2c 7b 52 30 2d 52 31  |TMFD.R13!,{R0-R1|
00000f40  32 2c 52 31 34 7d 0d 0a  3b 0d 0a 3b 20 46 69 72  |2,R14}..;..; Fir|
00000f50  73 74 20 74 68 69 6e 67  20 77 65 20 6e 65 65 64  |st thing we need|
00000f60  20 74 6f 20 64 6f 20 69  73 20 64 65 63 69 64 65  | to do is decide|
00000f70  20 69 66 20 77 65 27 72  65 20 74 6f 74 61 6c 6c  | if we're totall|
00000f80  79 20 6f 66 66 0d 0a 3b  0d 0a 09 4c 44 52 09 52  |y off..;...LDR.R|
00000f90  33 2c 5b 52 30 2c 23 30  5d 09 3b 20 57 69 64 74  |3,[R0,#0].; Widt|
00000fa0  68 20 6f 66 20 73 70 72  69 74 65 0d 0a 09 4c 44  |h of sprite...LD|
00000fb0  52 09 52 34 2c 5b 52 30  2c 23 34 5d 09 3b 20 48  |R.R4,[R0,#4].; H|
00000fc0  65 69 67 68 74 20 6f 66  20 73 70 72 69 74 65 0d  |eight of sprite.|
00000fd0  0a 09 41 44 44 09 52 33  2c 52 33 2c 23 31 0d 0a  |..ADD.R3,R3,#1..|
00000fe0  09 41 44 44 09 52 34 2c  52 34 2c 23 31 0d 0a 09  |.ADD.R4,R4,#1...|
00000ff0  41 44 44 09 52 33 2c 52  33 2c 52 31 09 3b 20 52  |ADD.R3,R3,R1.; R|
00001000  33 20 3d 20 66 75 72 74  68 65 73 74 20 72 69 67  |3 = furthest rig|
00001010  68 74 20 70 69 78 65 6c  20 74 6f 20 62 65 20 70  |ht pixel to be p|
00001020  6c 6f 74 74 65 64 0d 0a  09 41 44 44 09 52 34 2c  |lotted...ADD.R4,|
00001030  52 34 2c 52 32 09 3b 20  52 34 20 3d 20 6c 6f 77  |R4,R2.; R4 = low|
00001040  65 73 74 20 70 69 78 65  6c 20 74 6f 20 62 65 20  |est pixel to be |
00001050  70 6c 6f 74 74 65 64 0d  0a 09 4c 44 52 09 52 35  |plotted...LDR.R5|
00001060  2c 73 63 72 65 65 6e 5f  63 6c 69 70 5f 62 6f 74  |,screen_clip_bot|
00001070  74 6f 6d 0d 0a 09 4c 44  52 09 52 36 2c 73 63 72  |tom...LDR.R6,scr|
00001080  65 65 6e 5f 63 6c 69 70  5f 74 6f 70 0d 0a 09 4c  |een_clip_top...L|
00001090  44 52 09 52 37 2c 73 63  72 65 65 6e 5f 63 6c 69  |DR.R7,screen_cli|
000010a0  70 5f 6c 65 66 74 0d 0a  09 4c 44 52 09 52 38 2c  |p_left...LDR.R8,|
000010b0  73 63 72 65 65 6e 5f 63  6c 69 70 5f 72 69 67 68  |screen_clip_righ|
000010c0  74 0d 0a 09 43 4d 50 09  52 31 2c 52 38 0d 0a 09  |t...CMP.R1,R8...|
000010d0  4c 44 4d 47 54 46 44 09  52 31 33 21 2c 7b 52 30  |LDMGTFD.R13!,{R0|
000010e0  2d 52 31 32 2c 50 43 7d  5e 09 3b 20 4f 66 66 20  |-R12,PC}^.; Off |
000010f0  72 69 67 68 74 3f 0d 0a  09 43 4d 50 09 52 32 2c  |right?...CMP.R2,|
00001100  52 35 0d 0a 09 4c 44 4d  47 54 46 44 09 52 31 33  |R5...LDMGTFD.R13|
00001110  21 2c 7b 52 30 2d 52 31  32 2c 50 43 7d 5e 09 3b  |!,{R0-R12,PC}^.;|
00001120  20 4f 66 66 20 62 6f 74  74 6f 6d 3f 0d 0a 09 43  | Off bottom?...C|
00001130  4d 50 09 52 33 2c 52 37  0d 0a 09 4c 44 4d 4c 54  |MP.R3,R7...LDMLT|
00001140  46 44 09 52 31 33 21 2c  7b 52 30 2d 52 31 32 2c  |FD.R13!,{R0-R12,|
00001150  50 43 7d 5e 09 3b 20 4f  66 66 20 6c 65 66 74 3f  |PC}^.; Off left?|
00001160  0d 0a 09 43 4d 50 09 52  34 2c 52 36 0d 0a 09 4c  |...CMP.R4,R6...L|
00001170  44 4d 4c 54 46 44 09 52  31 33 21 2c 7b 52 30 2d  |DMLTFD.R13!,{R0-|
00001180  52 31 32 2c 50 43 7d 5e  09 3b 20 4f 66 66 20 74  |R12,PC}^.; Off t|
00001190  6f 70 3f 0d 0a 0d 0a 09  53 54 52 09 52 34 2c 6c  |op?.....STR.R4,l|
000011a0  61 73 74 5f 79 09 09 3b  20 53 74 6f 72 65 20 66  |ast_y..; Store f|
000011b0  6f 72 20 6c 61 74 65 72  0d 0a 09 53 54 52 09 52  |or later...STR.R|
000011c0  31 2c 66 69 72 73 74 5f  78 09 09 3b 20 6c 69 6b  |1,first_x..; lik|
000011d0  65 77 69 73 65 0d 0a 3b  0d 0a 3b 20 4e 6f 77 20  |ewise..;..; Now |
000011e0  77 65 20 6b 6e 6f 77 20  77 65 20 68 61 76 65 20  |we know we have |
000011f0  61 20 73 70 72 69 74 65  20 77 68 69 63 68 20 69  |a sprite which i|
00001200  73 20 61 74 20 6c 65 61  73 74 20 70 61 72 74 69  |s at least parti|
00001210  61 6c 6c 79 20 6f 6e 20  73 63 72 65 65 6e 2c 0d  |ally on screen,.|
00001220  0a 3b 20 77 65 20 6e 65  65 64 20 74 6f 20 66 69  |.; we need to fi|
00001230  6e 64 20 74 68 65 20 66  69 72 73 74 20 62 79 74  |nd the first byt|
00001240  65 20 74 6f 20 73 74 61  72 74 20 70 6c 6f 74 74  |e to start plott|
00001250  69 6e 67 20 61 74 20 6f  6e 20 74 68 65 20 66 69  |ing at on the fi|
00001260  73 72 74 0d 0a 3b 20 73  63 61 6e 20 6c 69 6e 65  |srt..; scan line|
00001270  0d 0a 3b 0d 0a 3b 20 53  74 61 72 74 20 3d 20 73  |..;..; Start = s|
00001280  63 72 65 65 6e 20 62 61  73 65 20 61 64 64 72 65  |creen base addre|
00001290  73 73 20 2b 20 78 20 70  6f 73 69 74 69 6f 6e 20  |ss + x position |
000012a0  2b 20 28 79 20 70 6f 73  69 74 69 6f 6e 20 2a 20  |+ (y position * |
000012b0  6c 69 6e 65 20 6c 65 6e  67 74 68 29 0d 0a 3b 0d  |line length)..;.|
000012c0  0a 09 4c 44 52 09 52 33  2c 73 63 72 65 65 6e 5f  |..LDR.R3,screen_|
000012d0  73 74 61 72 74 0d 0a 09  4c 44 52 09 52 34 2c 73  |start...LDR.R4,s|
000012e0  63 72 65 65 6e 5f 6c 61  73 74 78 70 69 78 0d 0a  |creen_lastxpix..|
000012f0  09 41 44 44 09 52 34 2c  52 34 2c 23 31 0d 0a 09  |.ADD.R4,R4,#1...|
00001300  4d 4c 41 09 52 31 31 2c  52 32 2c 52 34 2c 52 33  |MLA.R11,R2,R4,R3|
00001310  0d 0a 09 41 44 44 09 52  31 31 2c 52 31 31 2c 52  |...ADD.R11,R11,R|
00001320  31 0d 0a 3b 20 53 6f 20  6e 6f 77 20 77 65 27 6c  |1..; So now we'l|
00001330  6c 20 6b 65 65 70 20 52  31 31 20 61 73 20 6f 75  |l keep R11 as ou|
00001340  72 20 27 70 6c 6f 74 20  68 65 72 65 27 20 72 65  |r 'plot here' re|
00001350  67 69 73 74 65 72 0d 0a  0d 0a 3b 20 57 65 20 6e  |gister....; We n|
00001360  6f 77 20 6e 65 65 64 20  74 6f 20 66 69 6e 64 20  |ow need to find |
00001370  6f 75 74 20 77 68 65 72  65 20 74 6f 20 73 74 61  |out where to sta|
00001380  72 74 20 6c 6f 6f 6b 69  6e 67 20 66 6f 72 20 6f  |rt looking for o|
00001390  75 72 20 73 63 61 6e 2d  6c 69 6e 65 20 64 61 74  |ur scan-line dat|
000013a0  61 0d 0a 3b 20 77 68 69  63 68 20 69 73 20 64 65  |a..; which is de|
000013b0  74 65 72 6d 69 6e 65 64  20 62 79 20 77 68 69 63  |termined by whic|
000013c0  68 20 69 6d 61 67 65 20  63 6f 70 79 20 77 65 20  |h image copy we |
000013d0  63 68 6f 6f 73 65 2c 20  77 68 69 63 68 20 69 73  |choose, which is|
000013e0  0d 0a 3b 20 64 65 74 65  72 6d 69 6e 65 64 20 62  |..; determined b|
000013f0  79 20 77 68 61 74 20 61  6c 69 67 6e 6d 65 6e 74  |y what alignment|
00001400  20 77 65 20 77 61 6e 74  2e 20 20 53 65 65 3f 20  | we want.  See? |
00001410  3a 2d 29 0d 0a 3b 0d 0a  09 41 44 44 09 52 31 30  |:-)..;...ADD.R10|
00001420  2c 52 30 2c 23 38 0d 0a  09 41 4e 44 09 52 34 2c  |,R0,#8...AND.R4,|
00001430  52 31 2c 23 33 09 09 3b  20 52 34 20 3d 20 61 6c  |R1,#3..; R4 = al|
00001440  69 67 6e 6d 65 6e 74 0d  0a 09 41 44 44 09 52 31  |ignment...ADD.R1|
00001450  30 2c 52 31 30 2c 52 34  2c 4c 53 4c 23 32 0d 0a  |0,R10,R4,LSL#2..|
00001460  09 4c 44 52 09 52 31 30  2c 5b 52 31 30 5d 0d 0a  |.LDR.R10,[R10]..|
00001470  09 41 44 44 09 52 31 30  2c 52 31 30 2c 52 30 09  |.ADD.R10,R10,R0.|
00001480  09 3b 20 52 31 30 20 3e  20 73 74 61 72 74 20 6f  |.; R10 > start o|
00001490  66 20 73 63 61 6e 2d 6c  69 6e 65 20 64 61 74 61  |f scan-line data|
000014a0  20 70 74 72 73 0d 0a 09  53 54 52 09 52 31 30 2c  | ptrs...STR.R10,|
000014b0  6e 65 78 74 5f 73 63 61  6e 5f 6c 69 6e 65 5f 70  |next_scan_line_p|
000014c0  74 72 0d 0a 3b 0d 0a 3b  20 57 65 27 76 65 20 6e  |tr..;..; We've n|
000014d0  6f 77 20 67 6f 74 20 74  68 65 20 27 66 72 6f 6d  |ow got the 'from|
000014e0  27 20 61 6e 64 20 27 74  6f 27 20 61 64 64 72 65  |' and 'to' addre|
000014f0  73 73 65 73 2c 20 73 6f  20 73 74 61 72 74 20 70  |sses, so start p|
00001500  6c 6f 74 74 69 6e 67 20  6c 69 6e 65 73 20 6e 6f  |lotting lines no|
00001510  77 0d 0a 3b 20 51 75 69  63 6b 20 6c 69 73 74 20  |w..; Quick list |
00001520  6f 66 20 72 65 67 69 73  74 65 72 73 20 74 6f 20  |of registers to |
00001530  6b 65 65 70 20 68 6f 6c  64 20 6f 66 20 3a 20 52  |keep hold of : R|
00001540  31 30 20 3e 20 6e 65 78  74 20 73 63 61 6e 2d 6c  |10 > next scan-l|
00001550  69 6e 65 20 64 61 74 61  20 70 74 72 0d 0a 3b 09  |ine data ptr..;.|
00001560  09 09 09 09 20 20 20 20  52 31 31 20 3e 20 6e 65  |....    R11 > ne|
00001570  78 74 20 73 63 72 65 65  6e 20 61 64 64 72 65 73  |xt screen addres|
00001580  73 0d 0a 3b 09 09 09 09  09 20 20 20 20 52 31 32  |s..;.....    R12|
00001590  20 3e 20 6e 65 78 74 20  73 63 61 6e 2d 6c 69 6e  | > next scan-lin|
000015a0  65 20 64 61 74 61 0d 0a  3b 0d 0a 09 42 09 66 69  |e data..;...B.fi|
000015b0  72 73 74 5f 73 63 61 6e  5f 6c 69 6e 65 09 09 3b  |rst_scan_line..;|
000015c0  20 53 6b 69 70 20 62 69  74 20 74 6f 20 69 6e 63  | Skip bit to inc|
000015d0  72 65 61 73 65 20 63 6f  75 6e 74 65 72 73 0d 0a  |rease counters..|
000015e0  6e 65 78 74 5f 73 63 61  6e 5f 6c 69 6e 65 0d 0a  |next_scan_line..|
000015f0  09 41 44 44 09 52 32 2c  52 32 2c 23 31 0d 0a 09  |.ADD.R2,R2,#1...|
00001600  4c 44 52 09 52 33 2c 6c  61 73 74 5f 79 0d 0a 09  |LDR.R3,last_y...|
00001610  43 4d 50 09 52 32 2c 52  33 09 09 09 3b 20 43 68  |CMP.R2,R3...; Ch|
00001620  65 63 6b 20 77 65 27 76  65 20 6e 6f 74 20 66 69  |eck we've not fi|
00001630  6e 69 73 68 65 64 0d 0a  09 42 45 51 09 66 69 6e  |nished...BEQ.fin|
00001640  69 73 68 65 64 5f 70 6c  6f 74 0d 0a 09 4c 44 52  |ished_plot...LDR|
00001650  09 52 31 31 2c 6e 65 78  74 5f 73 63 61 6e 5f 6c  |.R11,next_scan_l|
00001660  69 6e 65 5f 61 64 64 72  65 73 73 20 3b 20 4d 6f  |ine_address ; Mo|
00001670  76 65 20 52 31 31 20 74  6f 20 6e 65 78 74 20 73  |ve R11 to next s|
00001680  63 61 6e 20 6c 69 6e 65  0d 0a 66 69 72 73 74 5f  |can line..first_|
00001690  73 63 61 6e 5f 6c 69 6e  65 09 09 09 09 3b 20 52  |scan_line....; R|
000016a0  65 67 69 73 74 65 72 73  20 61 6c 72 65 61 64 79  |egisters already|
000016b0  20 73 65 74 20 75 70 21  0d 0a 3b 0d 0a 3b 20 46  | set up!..;..; F|
000016c0  69 72 73 74 20 74 68 69  6e 67 20 74 6f 20 64 6f  |irst thing to do|
000016d0  20 69 73 20 77 6f 72 6b  20 6f 75 74 20 77 68 65  | is work out whe|
000016e0  72 65 20 74 68 65 20 73  74 61 72 74 20 6f 66 20  |re the start of |
000016f0  74 68 65 20 6e 65 78 74  20 73 63 61 6e 20 6c 69  |the next scan li|
00001700  6e 65 0d 0a 3b 20 73 68  6f 75 6c 64 20 62 65 20  |ne..; should be |
00001710  74 6f 20 61 76 6f 69 64  20 6d 65 73 73 79 20 63  |to avoid messy c|
00001720  61 6c 63 75 6c 61 74 69  6f 6e 73 20 6c 61 74 65  |alculations late|
00001730  72 0d 0a 3b 0d 0a 09 4c  44 52 09 52 33 2c 73 63  |r..;...LDR.R3,sc|
00001740  72 65 65 6e 5f 6c 61 73  74 78 70 69 78 0d 0a 09  |reen_lastxpix...|
00001750  41 44 44 09 52 33 2c 52  33 2c 23 31 0d 0a 09 41  |ADD.R3,R3,#1...A|
00001760  44 44 09 52 33 2c 52 33  2c 52 31 31 0d 0a 09 53  |DD.R3,R3,R11...S|
00001770  54 52 09 52 33 2c 6e 65  78 74 5f 73 63 61 6e 5f  |TR.R3,next_scan_|
00001780  6c 69 6e 65 5f 61 64 64  72 65 73 73 0d 0a 3b 0d  |line_address..;.|
00001790  0a 3b 0d 0a 3b 20 46 69  72 73 74 20 74 68 69 6e  |.;..; First thin|
000017a0  67 20 74 6f 20 63 68 65  63 6b 20 66 6f 72 20 69  |g to check for i|
000017b0  73 20 79 20 63 6c 69 70  70 69 6e 67 3b 20 69 66  |s y clipping; if|
000017c0  20 77 65 27 72 65 20 6e  6f 74 20 6f 6e 20 74 6f  | we're not on to|
000017d0  70 20 6f 72 20 62 6f 74  74 6f 6d 2c 0d 0a 3b 20  |p or bottom,..; |
000017e0  74 68 65 72 65 27 73 20  6e 6f 20 70 6f 69 6e 74  |there's no point|
000017f0  20 69 6e 20 67 6f 69 6e  67 20 61 6e 79 20 66 75  | in going any fu|
00001800  72 74 68 65 72 0d 0a 3b  0d 0a 09 4c 44 52 09 52  |rther..;...LDR.R|
00001810  33 2c 73 63 72 65 65 6e  5f 63 6c 69 70 5f 62 6f  |3,screen_clip_bo|
00001820  74 74 6f 6d 0d 0a 09 43  4d 50 09 52 32 2c 52 33  |ttom...CMP.R2,R3|
00001830  0d 0a 09 42 47 54 09 66  69 6e 69 73 68 65 64 5f  |...BGT.finished_|
00001840  70 6c 6f 74 09 09 3b 20  46 69 6e 69 73 68 65 64  |plot..; Finished|
00001850  20 69 66 20 77 65 27 72  65 20 6f 66 66 20 74 68  | if we're off th|
00001860  65 20 62 6f 74 74 6f 6d  0d 0a 09 4c 44 52 09 52  |e bottom...LDR.R|
00001870  33 2c 73 63 72 65 65 6e  5f 63 6c 69 70 5f 74 6f  |3,screen_clip_to|
00001880  70 0d 0a 09 43 4d 50 09  52 32 2c 52 33 0d 0a 09  |p...CMP.R2,R3...|
00001890  41 44 44 4c 54 09 52 31  30 2c 52 31 30 2c 23 34  |ADDLT.R10,R10,#4|
000018a0  0d 0a 09 42 4c 54 09 6e  65 78 74 5f 73 63 61 6e  |...BLT.next_scan|
000018b0  5f 6c 69 6e 65 09 09 3b  20 54 72 79 20 6e 65 78  |_line..; Try nex|
000018c0  74 20 6c 69 6e 65 20 69  66 20 77 65 27 72 65 20  |t line if we're |
000018d0  6f 66 66 20 74 68 65 20  74 6f 70 0d 0a 3b 0d 0a  |off the top..;..|
000018e0  3b 20 52 69 67 68 74 2c  20 6e 6f 77 20 77 65 20  |; Right, now we |
000018f0  6b 6e 6f 77 20 77 65 20  68 61 76 65 20 61 20 73  |know we have a s|
00001900  63 61 6e 20 6c 69 6e 65  20 77 68 69 63 68 20 69  |can line which i|
00001910  73 20 69 6e 20 74 68 65  20 70 6c 6f 74 20 77 69  |s in the plot wi|
00001920  6e 64 6f 77 0d 0a 3b 20  69 6e 20 74 68 65 20 79  |ndow..; in the y|
00001930  20 64 69 72 65 63 74 69  6f 6e 20 61 6e 79 77 61  | direction anywa|
00001940  79 2c 20 73 6f 20 77 65  20 6d 75 73 74 20 68 61  |y, so we must ha|
00001950  76 65 20 73 6f 6d 65 74  68 69 6e 67 20 74 6f 20  |ve something to |
00001960  70 6c 6f 74 2c 20 73 6f  20 67 65 74 0d 0a 3b 20  |plot, so get..; |
00001970  74 68 65 20 73 74 61 72  74 20 6f 66 20 74 68 65  |the start of the|
00001980  20 73 63 61 6e 20 6c 69  6e 65 20 64 61 74 61 0d  | scan line data.|
00001990  0a 3b 0d 0a 0d 0a 3b 0d  0a 3b 20 46 65 74 63 68  |.;....;..; Fetch|
000019a0  20 74 68 65 20 61 64 64  72 65 73 73 20 6f 66 20  | the address of |
000019b0  74 68 65 20 66 69 72 73  74 20 70 61 72 74 20 6f  |the first part o|
000019c0  66 20 74 68 65 20 73 63  61 6e 20 6c 69 6e 65 20  |f the scan line |
000019d0  69 6e 74 6f 20 52 31 32  0d 0a 3b 20 61 6e 64 20  |into R12..; and |
000019e0  6d 6f 76 65 20 52 31 30  20 61 6c 6f 6e 67 0d 0a  |move R10 along..|
000019f0  3b 0d 0a 09 4c 44 52 09  52 31 2c 66 69 72 73 74  |;...LDR.R1,first|
00001a00  5f 78 09 09 3b 20 52 65  73 65 74 20 52 31 20 74  |_x..; Reset R1 t|
00001a10  6f 20 73 74 61 72 74 20  6f 66 20 6c 69 6e 65 0d  |o start of line.|
00001a20  0a 09 4c 44 52 09 52 31  32 2c 5b 52 31 30 5d 2c  |..LDR.R12,[R10],|
00001a30  23 34 0d 0a 09 41 44 44  09 52 31 32 2c 52 31 32  |#4...ADD.R12,R12|
00001a40  2c 52 30 09 09 3b 20 47  65 74 20 73 63 61 6e 20  |,R0..; Get scan |
00001a50  6c 69 6e 65 20 70 74 72  20 69 6e 74 6f 20 52 31  |line ptr into R1|
00001a60  32 0d 0a 6e 65 78 74 5f  73 63 61 6e 5f 6c 69 6e  |2..next_scan_lin|
00001a70  65 5f 62 69 74 0d 0a 09  4c 44 52 09 52 39 2c 5b  |e_bit...LDR.R9,[|
00001a80  52 31 32 5d 2c 23 34 09  09 3b 20 47 65 74 20 61  |R12],#4..; Get a|
00001a90  63 74 69 6f 6e 20 63 6f  64 65 20 69 6e 74 6f 20  |ction code into |
00001aa0  52 39 0d 0a 09 4d 4f 56  09 52 38 2c 52 39 2c 4c  |R9...MOV.R8,R9,L|
00001ab0  53 52 23 32 34 09 09 3b  20 52 38 20 3d 20 61 63  |SR#24..; R8 = ac|
00001ac0  74 69 6f 6e 0d 0a 09 42  49 43 09 52 39 2c 52 39  |tion...BIC.R9,R9|
00001ad0  2c 23 26 46 46 30 30 30  30 30 30 09 3b 20 52 39  |,#&FF000000.; R9|
00001ae0  20 3d 20 6e 75 6d 62 65  72 20 6f 66 20 62 79 74  | = number of byt|
00001af0  65 73 0d 0a 3b 0d 0a 3b  20 4e 6f 77 20 74 61 6b  |es..;..; Now tak|
00001b00  65 20 73 6f 6d 65 20 61  63 74 69 6f 6e 20 6f 6e  |e some action on|
00001b10  20 52 38 2c 20 6f 72 20  72 61 74 68 65 72 20 6a  | R8, or rather j|
00001b20  75 73 74 20 63 68 65 63  6b 20 69 66 20 69 74 20  |ust check if it |
00001b30  69 73 20 7a 65 72 6f 0d  0a 3b 0d 0a 09 43 4d 50  |is zero..;...CMP|
00001b40  09 52 38 2c 23 32 0d 0a  09 42 47 54 09 75 68 5f  |.R8,#2...BGT.uh_|
00001b50  6f 68 0d 0a 09 43 4d 50  09 52 38 2c 23 30 0d 0a  |oh...CMP.R8,#0..|
00001b60  09 42 45 51 09 6e 65 78  74 5f 73 63 61 6e 5f 6c  |.BEQ.next_scan_l|
00001b70  69 6e 65 0d 0a 3b 20 4f  74 68 65 72 77 69 73 65  |ine..; Otherwise|
00001b80  20 77 6f 72 6b 20 6f 75  74 20 52 35 20 61 6e 64  | work out R5 and|
00001b90  20 63 61 72 72 79 20 6f  6e 0d 0a 09 41 44 44 09  | carry on...ADD.|
00001ba0  52 35 2c 52 31 2c 52 39  09 09 3b 20 52 35 20 3d  |R5,R1,R9..; R5 =|
00001bb0  20 78 20 70 6f 73 69 74  69 6f 6e 20 61 66 74 65  | x position afte|
00001bc0  72 20 70 6c 6f 74 0d 0a  3b 0d 0a 3b 20 57 65 20  |r plot..;..; We |
00001bd0  68 61 76 65 20 74 68 65  20 70 6f 73 69 74 69 6f  |have the positio|
00001be0  6e 73 20 6f 66 20 74 68  65 20 66 69 72 73 74 20  |ns of the first |
00001bf0  61 6e 64 20 6c 61 73 74  20 62 79 74 65 73 20 6f  |and last bytes o|
00001c00  66 20 74 68 65 20 27 62  69 74 27 2c 20 6e 6f 77  |f the 'bit', now|
00001c10  0d 0a 3b 20 77 6f 72 6b  20 6f 75 74 20 77 68 65  |..; work out whe|
00001c20  74 68 65 72 20 74 68 65  20 27 62 69 74 27 20 69  |ther the 'bit' i|
00001c30  73 20 66 75 6c 6c 79 20  6f 6e 2d 73 63 72 65 65  |s fully on-scree|
00001c40  6e 2c 20 6f 72 20 77 68  65 74 68 65 72 20 77 65  |n, or whether we|
00001c50  20 6e 65 65 64 0d 0a 3b  20 74 6f 20 64 6f 20 73  | need..; to do s|
00001c60  6f 6d 65 20 58 20 63 6c  69 70 70 69 6e 67 0d 0a  |ome X clipping..|
00001c70  3b 0d 0a 09 4c 44 52 09  52 33 2c 73 63 72 65 65  |;...LDR.R3,scree|
00001c80  6e 5f 63 6c 69 70 5f 6c  65 66 74 0d 0a 09 4c 44  |n_clip_left...LD|
00001c90  52 09 52 34 2c 73 63 72  65 65 6e 5f 63 6c 69 70  |R.R4,screen_clip|
00001ca0  5f 72 69 67 68 74 0d 0a  09 43 4d 50 09 52 31 2c  |_right...CMP.R1,|
00001cb0  52 33 0d 0a 09 42 4c 54  09 63 6c 69 70 5f 6c 65  |R3...BLT.clip_le|
00001cc0  66 74 0d 0a 09 43 4d 50  09 52 35 2c 52 34 0d 0a  |ft...CMP.R5,R4..|
00001cd0  09 42 47 54 09 63 6c 69  70 5f 72 69 67 68 74 0d  |.BGT.clip_right.|
00001ce0  0a 09 42 09 6e 6f 5f 63  6c 69 70 70 69 6e 67 0d  |..B.no_clipping.|
00001cf0  0a 3b 0d 0a 3b 20 52 65  6c 65 76 61 6e 74 20 72  |.;..; Relevant r|
00001d00  65 67 69 73 74 65 72 73  20 66 6f 72 20 58 20 63  |egisters for X c|
00001d10  6c 69 70 70 69 6e 67 20  2d 2d 20 70 61 79 20 61  |lipping -- pay a|
00001d20  74 74 65 6e 74 69 6f 6e  20 74 6f 20 74 68 69 73  |ttention to this|
00001d30  0d 0a 3b 0d 0a 3b 20 52  31 20 20 3d 20 78 20 63  |..;..; R1  = x c|
00001d40  6f 2d 6f 72 64 69 6e 61  74 65 20 74 6f 20 73 74  |o-ordinate to st|
00001d50  61 72 74 20 70 6c 6f 74  74 69 6e 67 20 28 63 6f  |art plotting (co|
00001d60  75 6c 64 20 62 65 20 6f  66 66 20 73 63 72 65 65  |uld be off scree|
00001d70  6e 3f 29 0d 0a 3b 20 52  32 20 20 3d 20 79 20 63  |n?)..; R2  = y c|
00001d80  6f 2d 6f 72 64 69 6e 61  74 65 20 74 6f 20 73 74  |o-ordinate to st|
00001d90  61 72 74 20 70 6c 6f 74  74 69 6e 67 0d 0a 3b 20  |art plotting..; |
00001da0  52 33 20 20 3d 20 66 69  72 73 74 20 78 20 70 69  |R3  = first x pi|
00001db0  78 65 6c 20 69 6e 20 77  69 6e 64 6f 77 0d 0a 3b  |xel in window..;|
00001dc0  20 52 34 20 20 3d 20 6c  61 73 74 20 78 20 70 69  | R4  = last x pi|
00001dd0  78 65 6c 20 69 6e 20 77  69 6e 64 6f 77 0d 0a 3b  |xel in window..;|
00001de0  20 52 35 20 20 3d 20 78  20 63 6f 2d 6f 72 64 69  | R5  = x co-ordi|
00001df0  6e 61 74 65 20 61 66 74  65 72 20 70 6c 6f 74 20  |nate after plot |
00001e00  28 6f 66 66 20 73 63 72  65 65 6e 3f 29 0d 0a 3b  |(off screen?)..;|
00001e10  20 52 38 20 20 3d 20 27  74 79 70 65 27 20 70 61  | R8  = 'type' pa|
00001e20  72 74 20 6f 66 20 74 79  70 65 20 77 6f 72 64 20  |rt of type word |
00001e30  28 69 2e 65 2e 20 74 74  29 0d 0a 3b 20 52 39 20  |(i.e. tt)..; R9 |
00001e40  20 3d 20 6e 75 6d 62 65  72 20 6f 66 20 62 79 74  | = number of byt|
00001e50  65 73 20 28 69 2e 65 2e  20 64 64 64 64 29 0d 0a  |es (i.e. dddd)..|
00001e60  3b 20 52 31 31 20 3d 20  73 63 72 65 65 6e 20 61  |; R11 = screen a|
00001e70  64 64 72 65 73 73 20 74  6f 20 73 74 61 72 74 0d  |ddress to start.|
00001e80  0a 3b 20 52 31 32 20 3d  20 73 74 61 72 74 20 61  |.; R12 = start a|
00001e90  64 64 72 65 73 73 20 6f  66 20 73 70 72 69 74 65  |ddress of sprite|
00001ea0  20 64 61 74 61 0d 0a 3b  0d 0a 63 6c 69 70 5f 6c  | data..;..clip_l|
00001eb0  65 66 74 0d 0a 09 43 4d  50 09 52 38 2c 23 32 0d  |eft...CMP.R8,#2.|
00001ec0  0a 09 42 4e 45 09 63 6c  69 70 5f 6c 65 66 74 5f  |..BNE.clip_left_|
00001ed0  62 69 74 5f 6f 6e 0d 0a  09 41 44 44 09 52 31 31  |bit_on...ADD.R11|
00001ee0  2c 52 31 31 2c 52 39 0d  0a 09 4d 4f 56 09 52 31  |,R11,R9...MOV.R1|
00001ef0  2c 52 35 0d 0a 09 42 09  6e 65 78 74 5f 73 63 61  |,R5...B.next_sca|
00001f00  6e 5f 6c 69 6e 65 5f 62  69 74 09 3b 20 44 65 61  |n_line_bit.; Dea|
00001f10  6c 20 77 69 74 68 20 6d  61 73 6b 73 20 62 79 20  |l with masks by |
00001f20  6a 75 73 74 20 73 68 69  66 74 69 6e 67 0d 0a 09  |just shifting...|
00001f30  09 09 09 09 3b 20 74 68  65 20 72 65 6c 65 76 61  |....; the releva|
00001f40  6e 74 20 70 6f 69 6e 74  65 72 73 20 6f 6e 0d 0a  |nt pointers on..|
00001f50  63 6c 69 70 5f 6c 65 66  74 5f 62 69 74 5f 6f 6e  |clip_left_bit_on|
00001f60  0d 0a 09 43 4d 50 09 52  35 2c 52 33 0d 0a 09 42  |...CMP.R5,R3...B|
00001f70  47 45 09 63 6c 69 70 5f  6c 65 66 74 5f 6e 6f 74  |GE.clip_left_not|
00001f80  5f 63 6f 6d 70 6c 65 74  65 6c 79 5f 6f 66 66 0d  |_completely_off.|
00001f90  0a 09 41 4e 44 09 52 37  2c 52 31 31 2c 23 33 0d  |..AND.R7,R11,#3.|
00001fa0  0a 09 41 44 44 09 52 31  32 2c 52 31 32 2c 52 37  |..ADD.R12,R12,R7|
00001fb0  09 09 3b 20 50 75 73 68  20 52 31 32 20 61 6c 6f  |..; Push R12 alo|
00001fc0  6e 67 20 61 63 63 6f 72  64 69 6e 67 20 74 6f 20  |ng according to |
00001fd0  61 6c 69 67 6e 0d 0a 09  41 44 44 09 52 31 32 2c  |align...ADD.R12,|
00001fe0  52 31 32 2c 52 39 0d 0a  09 41 44 44 09 52 31 31  |R12,R9...ADD.R11|
00001ff0  2c 52 31 31 2c 52 39 0d  0a 09 4d 4f 56 09 52 31  |,R11,R9...MOV.R1|
00002000  2c 52 35 0d 0a 09 42 09  61 6c 69 67 6e 5f 72 31  |,R5...B.align_r1|
00002010  32 5f 6e 6f 5f 72 65 73  74 6f 72 65 0d 0a 63 6c  |2_no_restore..cl|
00002020  69 70 5f 6c 65 66 74 5f  6e 6f 74 5f 63 6f 6d 70  |ip_left_not_comp|
00002030  6c 65 74 65 6c 79 5f 6f  66 66 0d 0a 09 41 4e 44  |letely_off...AND|
00002040  09 52 37 2c 52 31 31 2c  23 33 0d 0a 09 41 44 44  |.R7,R11,#3...ADD|
00002050  09 52 31 32 2c 52 31 32  2c 52 37 09 09 3b 20 50  |.R12,R12,R7..; P|
00002060  75 73 68 20 52 31 32 20  61 6c 6f 6e 67 20 61 63  |ush R12 along ac|
00002070  63 6f 72 64 69 6e 67 20  74 6f 20 61 6c 69 67 6e  |cording to align|
00002080  0d 0a 09 53 55 42 09 52  36 2c 52 33 2c 52 31 09  |...SUB.R6,R3,R1.|
00002090  09 3b 20 52 36 20 3d 20  6e 6f 2e 20 6f 66 20 70  |.; R6 = no. of p|
000020a0  69 78 65 6c 73 20 6f 66  66 20 6c 65 66 74 0d 0a  |ixels off left..|
000020b0  09 41 44 44 09 52 31 31  2c 52 31 31 2c 52 36 0d  |.ADD.R11,R11,R6.|
000020c0  0a 09 41 44 44 09 52 31  32 2c 52 31 32 2c 52 36  |..ADD.R12,R12,R6|
000020d0  0d 0a 09 4d 4f 56 09 52  31 2c 52 35 0d 0a 09 53  |...MOV.R1,R5...S|
000020e0  55 42 09 52 39 2c 52 39  2c 52 36 09 09 3b 20 41  |UB.R9,R9,R6..; A|
000020f0  64 6a 75 73 74 20 73 74  61 72 74 20 2f 20 6e 6f  |djust start / no|
00002100  2e 20 6f 66 20 70 69 78  65 6c 73 0d 0a 09 43 4d  |. of pixels...CM|
00002110  50 09 52 35 2c 52 34 09  09 09 3b 20 43 68 65 63  |P.R5,R4...; Chec|
00002120  6b 20 66 6f 72 20 63 6c  69 70 20 72 69 67 68 74  |k for clip right|
00002130  20 61 73 20 77 65 6c 6c  0d 0a 09 42 4c 45 09 73  | as well...BLE.s|
00002140  74 61 72 74 5f 70 6c 6f  74 5f 62 69 74 0d 0a 09  |tart_plot_bit...|
00002150  41 44 44 09 52 34 2c 52  34 2c 23 31 09 09 3b 0d  |ADD.R4,R4,#1..;.|
00002160  0a 09 53 55 42 09 52 36  2c 52 35 2c 52 34 09 09  |..SUB.R6,R5,R4..|
00002170  3b 20 43 6f 64 65 20 63  6f 70 69 65 64 20 66 72  |; Code copied fr|
00002180  6f 6d 20 62 65 6c 6f 77  0d 0a 09 53 54 52 09 52  |om below...STR.R|
00002190  36 2c 63 6f 6d 70 65 6e  73 61 74 65 5f 72 69 67  |6,compensate_rig|
000021a0  68 74 09 3b 0d 0a 09 53  55 42 09 52 39 2c 52 39  |ht.;...SUB.R9,R9|
000021b0  2c 52 36 09 09 3b 0d 0a  09 42 09 73 74 61 72 74  |,R6..;...B.start|
000021c0  5f 70 6c 6f 74 5f 62 69  74 09 09 3b 0d 0a 0d 0a  |_plot_bit..;....|
000021d0  63 6c 69 70 5f 72 69 67  68 74 0d 0a 09 43 4d 50  |clip_right...CMP|
000021e0  09 52 38 2c 23 32 0d 0a  09 42 45 51 09 6e 65 78  |.R8,#2...BEQ.nex|
000021f0  74 5f 73 63 61 6e 5f 6c  69 6e 65 09 09 3b 20 4d  |t_scan_line..; M|
00002200  61 73 6b 20 6f 66 66 20  72 69 67 68 74 20 2d 3e  |ask off right ->|
00002210  20 6e 65 78 74 20 6c 69  6e 65 0d 0a 09 41 44 44  | next line...ADD|
00002220  09 52 34 2c 52 34 2c 23  31 09 09 3b 20 41 72 73  |.R4,R4,#1..; Ars|
00002230  65 0d 0a 09 53 55 42 09  52 36 2c 52 35 2c 52 34  |e...SUB.R6,R5,R4|
00002240  09 09 3b 20 52 36 20 3d  20 6e 6f 2e 20 6f 66 20  |..; R6 = no. of |
00002250  70 69 78 65 6c 73 20 6f  66 66 20 72 69 67 68 74  |pixels off right|
00002260  0d 0a 09 53 54 52 09 52  36 2c 63 6f 6d 70 65 6e  |...STR.R6,compen|
00002270  73 61 74 65 5f 72 69 67  68 74 09 3b 20 43 6f 6d  |sate_right.; Com|
00002280  70 65 6e 73 61 74 65 20  61 66 74 65 72 20 70 6c  |pensate after pl|
00002290  6f 74 0d 0a 09 53 55 42  09 52 39 2c 52 39 2c 52  |ot...SUB.R9,R9,R|
000022a0  36 09 09 3b 20 43 6c 69  70 20 70 69 78 65 6c 73  |6..; Clip pixels|
000022b0  20 6f 66 66 20 72 69 67  68 74 0d 0a 09 4d 4f 56  | off right...MOV|
000022c0  09 52 31 2c 52 35 0d 0a  09 41 4e 44 09 52 33 2c  |.R1,R5...AND.R3,|
000022d0  52 31 31 2c 23 33 0d 0a  09 41 44 44 09 52 31 32  |R11,#3...ADD.R12|
000022e0  2c 52 31 32 2c 52 33 0d  0a 09 42 09 73 74 61 72  |,R12,R3...B.star|
000022f0  74 5f 70 6c 6f 74 5f 62  69 74 0d 0a 0d 0a 6e 6f  |t_plot_bit....no|
00002300  5f 63 6c 69 70 70 69 6e  67 0d 0a 09 41 44 44 09  |_clipping...ADD.|
00002310  52 31 2c 52 31 2c 52 39  09 09 3b 20 41 64 6a 75  |R1,R1,R9..; Adju|
00002320  73 74 20 58 0d 0a 09 43  4d 50 09 52 38 2c 23 32  |st X...CMP.R8,#2|
00002330  0d 0a 09 41 44 44 45 51  09 52 31 31 2c 52 31 31  |...ADDEQ.R11,R11|
00002340  2c 52 39 0d 0a 09 42 45  51 09 6e 65 78 74 5f 73  |,R9...BEQ.next_s|
00002350  63 61 6e 5f 6c 69 6e 65  5f 62 69 74 09 3b 20 53  |can_line_bit.; S|
00002360  6b 69 70 20 73 63 72 65  65 6e 20 6d 65 6d 6f 72  |kip screen memor|
00002370  79 20 69 66 20 69 74 27  73 20 61 20 6d 61 73 6b  |y if it's a mask|
00002380  0d 0a 09 41 4e 44 09 52  33 2c 52 31 31 2c 23 33  |...AND.R3,R11,#3|
00002390  09 09 3b 20 47 65 74 20  61 6c 69 67 6e 6d 65 6e  |..; Get alignmen|
000023a0  74 20 6f 66 20 73 63 72  65 65 6e 20 61 64 64 72  |t of screen addr|
000023b0  65 73 73 0d 0a 09 41 44  44 09 52 31 32 2c 52 31  |ess...ADD.R12,R1|
000023c0  32 2c 52 33 09 09 3b 20  41 64 6a 75 73 74 20 73  |2,R3..; Adjust s|
000023d0  74 61 72 74 20 6f 66 20  64 61 74 61 0d 0a 3b 0d  |tart of data..;.|
000023e0  0a 3b 20 52 69 67 68 74  2c 20 68 65 72 65 20 69  |.; Right, here i|
000023f0  73 20 77 68 65 72 65 20  77 65 20 63 61 6e 20 73  |s where we can s|
00002400  74 61 72 74 20 70 6c 6f  74 74 69 6e 67 21 0d 0a  |tart plotting!..|
00002410  3b 20 20 20 52 31 32 20  3e 20 73 70 72 69 74 65  |;   R12 > sprite|
00002420  20 64 61 74 61 20 28 61  6c 69 67 6e 65 64 2c 20  | data (aligned, |
00002430  73 6f 20 77 61 74 63 68  20 66 6f 72 20 7a 65 72  |so watch for zer|
00002440  6f 65 73 20 61 74 20 73  74 61 72 74 29 0d 0a 3b  |oes at start)..;|
00002450  20 20 20 52 31 31 20 3e  20 73 63 72 65 65 6e 20  |   R11 > screen |
00002460  6d 65 6d 6f 72 79 20 74  6f 20 73 74 61 72 74 20  |memory to start |
00002470  28 61 64 6a 75 73 74 65  64 20 66 6f 72 20 63 6c  |(adjusted for cl|
00002480  69 70 70 69 6e 67 29 0d  0a 3b 20 20 20 52 39 20  |ipping)..;   R9 |
00002490  20 3d 20 6e 75 6d 62 65  72 20 6f 66 20 62 79 74  | = number of byt|
000024a0  65 73 20 74 6f 20 70 6c  6f 74 0d 0a 3b 0d 0a 73  |es to plot..;..s|
000024b0  74 61 72 74 5f 70 6c 6f  74 5f 62 69 74 0d 0a 09  |tart_plot_bit...|
000024c0  53 54 4d 46 44 09 52 31  33 21 2c 7b 52 30 2d 52  |STMFD.R13!,{R0-R|
000024d0  37 7d 09 09 3b 20 4b 65  65 70 20 73 63 72 61 74  |7}..; Keep scrat|
000024e0  63 68 20 72 65 67 69 73  74 65 72 73 0d 0a 09 09  |ch registers....|
000024f0  09 09 09 3b 20 27 63 6f  73 20 77 65 27 72 65 20  |...; 'cos we're |
00002500  67 6f 69 6e 67 20 74 6f  20 6f 76 65 72 77 72 69  |going to overwri|
00002510  74 65 20 74 68 65 6d 0d  0a 09 09 09 09 09 3b 20  |te them.......; |
00002520  77 69 74 68 20 6d 75 6c  74 69 70 6c 65 20 6c 6f  |with multiple lo|
00002530  61 64 73 2f 73 74 6f 72  65 73 0d 0a 3b 0d 0a 3b  |ads/stores..;..;|
00002540  20 50 6c 6f 74 20 30 2d  33 20 62 79 74 65 73 20  | Plot 0-3 bytes |
00002550  73 6f 20 77 65 20 73 74  61 72 74 20 6f 6e 20 61  |so we start on a|
00002560  20 77 6f 72 64 20 62 6f  75 6e 64 61 72 79 0d 0a  | word boundary..|
00002570  3b 0d 0a 09 43 4d 50 09  52 39 2c 23 30 0d 0a 09  |;...CMP.R9,#0...|
00002580  42 4c 45 09 61 6c 69 67  6e 5f 72 31 32 0d 0a 09  |BLE.align_r12...|
00002590  54 53 54 09 52 31 31 2c  23 31 0d 0a 09 42 45 51  |TST.R11,#1...BEQ|
000025a0  09 6e 6f 5f 61 6c 69 67  6e 5f 30 0d 0a 09 4c 44  |.no_align_0...LD|
000025b0  52 42 09 52 30 2c 5b 52  31 32 5d 2c 23 31 0d 0a  |RB.R0,[R12],#1..|
000025c0  09 53 54 52 42 09 52 30  2c 5b 52 31 31 5d 2c 23  |.STRB.R0,[R11],#|
000025d0  31 0d 0a 09 53 55 42 53  09 52 39 2c 52 39 2c 23  |1...SUBS.R9,R9,#|
000025e0  31 0d 0a 09 42 45 51 09  61 6c 69 67 6e 5f 72 31  |1...BEQ.align_r1|
000025f0  32 0d 0a 6e 6f 5f 61 6c  69 67 6e 5f 30 0d 0a 09  |2..no_align_0...|
00002600  54 53 54 09 52 31 31 2c  23 32 0d 0a 09 42 45 51  |TST.R11,#2...BEQ|
00002610  09 6e 6f 5f 61 6c 69 67  6e 5f 31 0d 0a 09 4c 44  |.no_align_1...LD|
00002620  52 42 09 52 30 2c 5b 52  31 32 5d 2c 23 31 0d 0a  |RB.R0,[R12],#1..|
00002630  09 53 54 52 42 09 52 30  2c 5b 52 31 31 5d 2c 23  |.STRB.R0,[R11],#|
00002640  31 0d 0a 09 53 55 42 53  09 52 39 2c 52 39 2c 23  |1...SUBS.R9,R9,#|
00002650  31 0d 0a 09 42 45 51 09  61 6c 69 67 6e 5f 72 31  |1...BEQ.align_r1|
00002660  32 0d 0a 09 4c 44 52 42  09 52 30 2c 5b 52 31 32  |2...LDRB.R0,[R12|
00002670  5d 2c 23 31 0d 0a 09 53  54 52 42 09 52 30 2c 5b  |],#1...STRB.R0,[|
00002680  52 31 31 5d 2c 23 31 0d  0a 09 53 55 42 53 09 52  |R11],#1...SUBS.R|
00002690  39 2c 52 39 2c 23 31 0d  0a 09 42 45 51 09 61 6c  |9,R9,#1...BEQ.al|
000026a0  69 67 6e 5f 72 31 32 0d  0a 6e 6f 5f 61 6c 69 67  |ign_r12..no_alig|
000026b0  6e 5f 31 0d 0a 0d 0a 3b  0d 0a 3b 20 4e 6f 77 20  |n_1....;..; Now |
000026c0  77 65 27 72 65 20 6f 6e  20 61 20 77 6f 72 64 20  |we're on a word |
000026d0  62 6f 75 6e 64 61 72 79  2c 20 77 65 20 63 61 6e  |boundary, we can|
000026e0  20 73 74 61 72 74 20 70  6c 6f 74 74 69 6e 67 20  | start plotting |
000026f0  62 69 67 20 63 68 75 6e  6b 73 20 77 69 74 68 0d  |big chunks with.|
00002700  0a 3b 20 4c 44 52 20 61  6e 64 20 4c 44 4d 20 69  |.; LDR and LDM i|
00002710  6e 73 74 72 75 63 74 69  6f 6e 73 0d 0a 3b 0d 0a  |nstructions..;..|
00002720  09 54 53 54 09 52 39 2c  23 32 5f 31 30 30 0d 0a  |.TST.R9,#2_100..|
00002730  09 42 45 51 09 6e 6f 5f  62 69 74 5f 32 0d 0a 09  |.BEQ.no_bit_2...|
00002740  4c 44 52 09 52 30 2c 5b  52 31 32 5d 2c 23 34 0d  |LDR.R0,[R12],#4.|
00002750  0a 09 53 54 52 09 52 30  2c 5b 52 31 31 5d 2c 23  |..STR.R0,[R11],#|
00002760  34 0d 0a 09 42 49 43 53  09 52 30 2c 52 39 2c 23  |4...BICS.R0,R9,#|
00002770  32 5f 31 31 31 0d 0a 09  42 45 51 09 6e 6f 5f 62  |2_111...BEQ.no_b|
00002780  69 74 5f 38 0d 0a 6e 6f  5f 62 69 74 5f 32 0d 0a  |it_8..no_bit_2..|
00002790  09 54 53 54 09 52 39 2c  23 32 5f 31 30 30 30 0d  |.TST.R9,#2_1000.|
000027a0  0a 09 42 45 51 09 6e 6f  5f 62 69 74 5f 33 0d 0a  |..BEQ.no_bit_3..|
000027b0  09 4c 44 4d 49 41 09 52  31 32 21 2c 7b 52 30 2d  |.LDMIA.R12!,{R0-|
000027c0  52 31 7d 0d 0a 09 53 54  4d 49 41 09 52 31 31 21  |R1}...STMIA.R11!|
000027d0  2c 7b 52 30 2d 52 31 7d  0d 0a 6e 6f 5f 62 69 74  |,{R0-R1}..no_bit|
000027e0  5f 33 0d 0a 09 54 53 54  09 52 39 2c 23 32 5f 31  |_3...TST.R9,#2_1|
000027f0  30 30 30 30 0d 0a 09 42  45 51 09 6e 6f 5f 62 69  |0000...BEQ.no_bi|
00002800  74 5f 34 0d 0a 09 4c 44  4d 49 41 09 52 31 32 21  |t_4...LDMIA.R12!|
00002810  2c 7b 52 30 2d 52 33 7d  0d 0a 09 53 54 4d 49 41  |,{R0-R3}...STMIA|
00002820  09 52 31 31 21 2c 7b 52  30 2d 52 33 7d 0d 0a 6e  |.R11!,{R0-R3}..n|
00002830  6f 5f 62 69 74 5f 34 0d  0a 09 54 53 54 09 52 39  |o_bit_4...TST.R9|
00002840  2c 23 32 5f 31 30 30 30  30 30 0d 0a 09 42 45 51  |,#2_100000...BEQ|
00002850  09 6e 6f 5f 62 69 74 5f  35 0d 0a 09 4c 44 4d 49  |.no_bit_5...LDMI|
00002860  41 09 52 31 32 21 2c 7b  52 30 2d 52 37 7d 0d 0a  |A.R12!,{R0-R7}..|
00002870  09 53 54 4d 49 41 09 52  31 31 21 2c 7b 52 30 2d  |.STMIA.R11!,{R0-|
00002880  52 37 7d 0d 0a 6e 6f 5f  62 69 74 5f 35 0d 0a 09  |R7}..no_bit_5...|
00002890  54 53 54 09 52 39 2c 23  32 5f 31 30 30 30 30 30  |TST.R9,#2_100000|
000028a0  30 0d 0a 09 42 45 51 09  6e 6f 5f 62 69 74 5f 36  |0...BEQ.no_bit_6|
000028b0  0d 0a 09 4c 44 4d 49 41  09 52 31 32 21 2c 7b 52  |...LDMIA.R12!,{R|
000028c0  30 2d 52 37 7d 0d 0a 09  53 54 4d 49 41 09 52 31  |0-R7}...STMIA.R1|
000028d0  31 21 2c 7b 52 30 2d 52  37 7d 0d 0a 09 4c 44 4d  |1!,{R0-R7}...LDM|
000028e0  49 41 09 52 31 32 21 2c  7b 52 30 2d 52 37 7d 0d  |IA.R12!,{R0-R7}.|
000028f0  0a 09 53 54 4d 49 41 09  52 31 31 21 2c 7b 52 30  |..STMIA.R11!,{R0|
00002900  2d 52 37 7d 0d 0a 6e 6f  5f 62 69 74 5f 36 0d 0a  |-R7}..no_bit_6..|
00002910  09 54 53 54 09 52 39 2c  23 32 5f 31 30 30 30 30  |.TST.R9,#2_10000|
00002920  30 30 30 0d 0a 09 42 45  51 09 6e 6f 5f 62 69 74  |000...BEQ.no_bit|
00002930  5f 37 0d 0a 09 4c 44 4d  49 41 09 52 31 32 21 2c  |_7...LDMIA.R12!,|
00002940  7b 52 30 2d 52 37 7d 0d  0a 09 53 54 4d 49 41 09  |{R0-R7}...STMIA.|
00002950  52 31 31 21 2c 7b 52 30  2d 52 37 7d 0d 0a 09 4c  |R11!,{R0-R7}...L|
00002960  44 4d 49 41 09 52 31 32  21 2c 7b 52 30 2d 52 37  |DMIA.R12!,{R0-R7|
00002970  7d 0d 0a 09 53 54 4d 49  41 09 52 31 31 21 2c 7b  |}...STMIA.R11!,{|
00002980  52 30 2d 52 37 7d 0d 0a  09 4c 44 4d 49 41 09 52  |R0-R7}...LDMIA.R|
00002990  31 32 21 2c 7b 52 30 2d  52 37 7d 0d 0a 09 53 54  |12!,{R0-R7}...ST|
000029a0  4d 49 41 09 52 31 31 21  2c 7b 52 30 2d 52 37 7d  |MIA.R11!,{R0-R7}|
000029b0  0d 0a 09 4c 44 4d 49 41  09 52 31 32 21 2c 7b 52  |...LDMIA.R12!,{R|
000029c0  30 2d 52 37 7d 0d 0a 09  53 54 4d 49 41 09 52 31  |0-R7}...STMIA.R1|
000029d0  31 21 2c 7b 52 30 2d 52  37 7d 0d 0a 6e 6f 5f 62  |1!,{R0-R7}..no_b|
000029e0  69 74 5f 37 0d 0a 09 54  53 54 09 52 39 2c 23 32  |it_7...TST.R9,#2|
000029f0  5f 31 30 30 30 30 30 30  30 30 0d 0a 09 42 45 51  |_100000000...BEQ|
00002a00  09 6e 6f 5f 62 69 74 5f  38 0d 0a 09 4c 44 4d 49  |.no_bit_8...LDMI|
00002a10  41 09 52 31 32 21 2c 7b  52 30 2d 52 37 7d 0d 0a  |A.R12!,{R0-R7}..|
00002a20  09 53 54 4d 49 41 09 52  31 31 21 2c 7b 52 30 2d  |.STMIA.R11!,{R0-|
00002a30  52 37 7d 0d 0a 09 4c 44  4d 49 41 09 52 31 32 21  |R7}...LDMIA.R12!|
00002a40  2c 7b 52 30 2d 52 37 7d  0d 0a 09 53 54 4d 49 41  |,{R0-R7}...STMIA|
00002a50  09 52 31 31 21 2c 7b 52  30 2d 52 37 7d 0d 0a 09  |.R11!,{R0-R7}...|
00002a60  4c 44 4d 49 41 09 52 31  32 21 2c 7b 52 30 2d 52  |LDMIA.R12!,{R0-R|
00002a70  37 7d 0d 0a 09 53 54 4d  49 41 09 52 31 31 21 2c  |7}...STMIA.R11!,|
00002a80  7b 52 30 2d 52 37 7d 0d  0a 09 4c 44 4d 49 41 09  |{R0-R7}...LDMIA.|
00002a90  52 31 32 21 2c 7b 52 30  2d 52 37 7d 0d 0a 09 53  |R12!,{R0-R7}...S|
00002aa0  54 4d 49 41 09 52 31 31  21 2c 7b 52 30 2d 52 37  |TMIA.R11!,{R0-R7|
00002ab0  7d 0d 0a 09 4c 44 4d 49  41 09 52 31 32 21 2c 7b  |}...LDMIA.R12!,{|
00002ac0  52 30 2d 52 37 7d 0d 0a  09 53 54 4d 49 41 09 52  |R0-R7}...STMIA.R|
00002ad0  31 31 21 2c 7b 52 30 2d  52 37 7d 0d 0a 09 4c 44  |11!,{R0-R7}...LD|
00002ae0  4d 49 41 09 52 31 32 21  2c 7b 52 30 2d 52 37 7d  |MIA.R12!,{R0-R7}|
00002af0  0d 0a 09 53 54 4d 49 41  09 52 31 31 21 2c 7b 52  |...STMIA.R11!,{R|
00002b00  30 2d 52 37 7d 0d 0a 09  4c 44 4d 49 41 09 52 31  |0-R7}...LDMIA.R1|
00002b10  32 21 2c 7b 52 30 2d 52  37 7d 0d 0a 09 53 54 4d  |2!,{R0-R7}...STM|
00002b20  49 41 09 52 31 31 21 2c  7b 52 30 2d 52 37 7d 0d  |IA.R11!,{R0-R7}.|
00002b30  0a 09 4c 44 4d 49 41 09  52 31 32 21 2c 7b 52 30  |..LDMIA.R12!,{R0|
00002b40  2d 52 37 7d 0d 0a 09 53  54 4d 49 41 09 52 31 31  |-R7}...STMIA.R11|
00002b50  21 2c 7b 52 30 2d 52 37  7d 0d 0a 6e 6f 5f 62 69  |!,{R0-R7}..no_bi|
00002b60  74 5f 38 0d 0a 3b 0d 0a  3b 20 4e 6f 77 20 77 65  |t_8..;..; Now we|
00002b70  20 73 68 6f 75 6c 64 20  68 61 76 65 20 70 6c 6f  | should have plo|
00002b80  74 74 65 64 20 61 6c 6c  20 62 75 74 20 74 68 65  |tted all but the|
00002b90  20 6c 61 73 74 20 30 2d  33 20 62 79 74 65 73 0d  | last 0-3 bytes.|
00002ba0  0a 3b 0d 0a 09 54 53 54  09 52 39 2c 23 32 5f 31  |.;...TST.R9,#2_1|
00002bb0  0d 0a 09 42 45 51 09 6e  6f 5f 62 69 74 5f 30 0d  |...BEQ.no_bit_0.|
00002bc0  0a 09 4c 44 52 42 09 52  30 2c 5b 52 31 32 5d 2c  |..LDRB.R0,[R12],|
00002bd0  23 31 0d 0a 09 53 54 52  42 09 52 30 2c 5b 52 31  |#1...STRB.R0,[R1|
00002be0  31 5d 2c 23 31 0d 0a 6e  6f 5f 62 69 74 5f 30 0d  |1],#1..no_bit_0.|
00002bf0  0a 09 54 53 54 09 52 39  2c 23 32 5f 31 30 0d 0a  |..TST.R9,#2_10..|
00002c00  09 42 45 51 09 6e 6f 5f  62 69 74 5f 31 0d 0a 09  |.BEQ.no_bit_1...|
00002c10  4c 44 52 42 09 52 30 2c  5b 52 31 32 5d 2c 23 31  |LDRB.R0,[R12],#1|
00002c20  0d 0a 09 53 54 52 42 09  52 30 2c 5b 52 31 31 5d  |...STRB.R0,[R11]|
00002c30  2c 23 31 0d 0a 09 4c 44  52 42 09 52 30 2c 5b 52  |,#1...LDRB.R0,[R|
00002c40  31 32 5d 2c 23 31 0d 0a  09 53 54 52 42 09 52 30  |12],#1...STRB.R0|
00002c50  2c 5b 52 31 31 5d 2c 23  31 0d 0a 6e 6f 5f 62 69  |,[R11],#1..no_bi|
00002c60  74 5f 31 0d 0a 3b 0d 0a  3b 20 4e 6f 77 20 77 65  |t_1..;..; Now we|
00002c70  20 6e 65 65 64 20 74 6f  20 61 6c 69 67 6e 20 52  | need to align R|
00002c80  31 32 20 73 6f 20 74 68  61 74 20 69 74 20 70 6f  |12 so that it po|
00002c90  69 6e 74 73 20 74 6f 20  74 68 65 20 6e 65 78 74  |ints to the next|
00002ca0  20 27 74 79 70 65 27 20  77 6f 72 64 2c 0d 0a 3b  | 'type' word,..;|
00002cb0  20 73 69 6e 63 65 20 69  74 20 63 6f 75 6c 64 20  | since it could |
00002cc0  62 65 20 73 74 72 61 67  67 6c 69 6e 67 20 61 74  |be straggling at|
00002cd0  20 61 20 6e 6f 6e 20 77  6f 72 64 2d 61 6c 69 67  | a non word-alig|
00002ce0  6e 65 64 20 70 6f 73 69  74 69 6f 6e 2e 0d 0a 3b  |ned position...;|
00002cf0  0d 0a 61 6c 69 67 6e 5f  72 31 32 0d 0a 09 4c 44  |..align_r12...LD|
00002d00  4d 46 44 09 52 31 33 21  2c 7b 52 30 2d 52 37 7d  |MFD.R13!,{R0-R7}|
00002d10  09 09 3b 20 52 65 73 74  6f 72 65 20 73 63 72 61  |..; Restore scra|
00002d20  74 63 68 20 72 65 67 69  73 74 65 72 73 0d 0a 61  |tch registers..a|
00002d30  6c 69 67 6e 5f 72 31 32  5f 6e 6f 5f 72 65 73 74  |lign_r12_no_rest|
00002d40  6f 72 65 0d 0a 09 4c 44  52 09 52 33 2c 63 6f 6d  |ore...LDR.R3,com|
00002d50  70 65 6e 73 61 74 65 5f  72 69 67 68 74 0d 0a 09  |pensate_right...|
00002d60  41 44 44 09 52 31 32 2c  52 31 32 2c 52 33 0d 0a  |ADD.R12,R12,R3..|
00002d70  09 4d 4f 56 09 52 33 2c  23 30 0d 0a 09 53 54 52  |.MOV.R3,#0...STR|
00002d80  09 52 33 2c 63 6f 6d 70  65 6e 73 61 74 65 5f 72  |.R3,compensate_r|
00002d90  69 67 68 74 0d 0a 09 41  44 44 09 52 31 32 2c 52  |ight...ADD.R12,R|
00002da0  31 32 2c 23 33 0d 0a 09  42 49 43 09 52 31 32 2c  |12,#3...BIC.R12,|
00002db0  52 31 32 2c 23 33 0d 0a  6e 6f 5f 61 6c 69 67 6e  |R12,#3..no_align|
00002dc0  0d 0a 09 42 09 6e 65 78  74 5f 73 63 61 6e 5f 6c  |...B.next_scan_l|
00002dd0  69 6e 65 5f 62 69 74 0d  0a 66 69 6e 69 73 68 65  |ine_bit..finishe|
00002de0  64 5f 70 6c 6f 74 0d 0a  09 4c 44 4d 46 44 09 52  |d_plot...LDMFD.R|
00002df0  31 33 21 2c 7b 52 30 2d  52 31 32 2c 50 43 7d 5e  |13!,{R0-R12,PC}^|
00002e00  0d 0a 3b 0d 0a 3b 20 54  68 69 73 20 73 68 6f 75  |..;..; This shou|
00002e10  6c 64 20 6e 65 76 65 72  20 68 61 70 70 65 6e 20  |ld never happen |
00002e20  3a 2d 29 0d 0a 3b 0d 0a  75 68 5f 6f 68 0d 0a 09  |:-)..;..uh_oh...|
00002e30  41 44 52 09 52 30 2c 65  72 72 6f 72 0d 0a 09 53  |ADR.R0,error...S|
00002e40  57 49 09 26 32 42 20 3b  20 4f 53 5f 47 65 6e 65  |WI.&2B ; OS_Gene|
00002e50  72 61 74 65 45 72 72 6f  72 0d 0a 0d 0a 65 72 72  |rateError....err|
00002e60  6f 72 09 26 20 30 0d 0a  09 44 43 42 20 22 54 79  |or.& 0...DCB "Ty|
00002e70  70 65 20 77 6f 72 64 20  6f 75 74 20 6f 66 20 72  |pe word out of r|
00002e80  61 6e 67 65 20 28 30 2d  32 29 22 2c 30 0d 0a 09  |ange (0-2)",0...|
00002e90  41 4c 49 47 4e 0d 0a 0d  0a 6c 61 73 74 5f 79 09  |ALIGN....last_y.|
00002ea0  09 09 26 20 30 0d 0a 66  69 72 73 74 5f 78 09 09  |..& 0..first_x..|
00002eb0  09 26 20 30 0d 0a 6e 65  78 74 5f 73 63 61 6e 5f  |.& 0..next_scan_|
00002ec0  6c 69 6e 65 5f 61 64 64  72 65 73 73 09 26 20 30  |line_address.& 0|
00002ed0  0d 0a 6e 65 78 74 5f 73  63 61 6e 5f 6c 69 6e 65  |..next_scan_line|
00002ee0  5f 70 74 72 09 26 20 30  0d 0a 63 6f 6d 70 65 6e  |_ptr.& 0..compen|
00002ef0  73 61 74 65 5f 72 69 67  68 74 09 26 20 30 0d 0a  |sate_right.& 0..|
00002f00  0d 0a 20 45 4e 44 0d 0a                           |.. END..|
00002f08