Home » Archimedes archive » Acorn User » AU 1997-01 B.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 1997-01 B.adf » Features |
Filename: | Arcade/!Popcorn/s/Plotters |
Read OK: | ✔ |
File size: | 2F22 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 BGT next_scan_line_bit 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 3b 09 42 47 54 09 75 68 |.R8,#2..;.BGT.uh| 00001b50 5f 6f 68 0d 0a 09 42 47 54 09 6e 65 78 74 5f 73 |_oh...BGT.next_s| 00001b60 63 61 6e 5f 6c 69 6e 65 5f 62 69 74 0d 0a 09 43 |can_line_bit...C| 00001b70 4d 50 09 52 38 2c 23 30 0d 0a 09 42 45 51 09 6e |MP.R8,#0...BEQ.n| 00001b80 65 78 74 5f 73 63 61 6e 5f 6c 69 6e 65 0d 0a 3b |ext_scan_line..;| 00001b90 20 4f 74 68 65 72 77 69 73 65 20 77 6f 72 6b 20 | Otherwise work | 00001ba0 6f 75 74 20 52 35 20 61 6e 64 20 63 61 72 72 79 |out R5 and carry| 00001bb0 20 6f 6e 0d 0a 09 41 44 44 09 52 35 2c 52 31 2c | on...ADD.R5,R1,| 00001bc0 52 39 09 09 3b 20 52 35 20 3d 20 78 20 70 6f 73 |R9..; R5 = x pos| 00001bd0 69 74 69 6f 6e 20 61 66 74 65 72 20 70 6c 6f 74 |ition after plot| 00001be0 0d 0a 3b 0d 0a 3b 20 57 65 20 68 61 76 65 20 74 |..;..; We have t| 00001bf0 68 65 20 70 6f 73 69 74 69 6f 6e 73 20 6f 66 20 |he positions of | 00001c00 74 68 65 20 66 69 72 73 74 20 61 6e 64 20 6c 61 |the first and la| 00001c10 73 74 20 62 79 74 65 73 20 6f 66 20 74 68 65 20 |st bytes of the | 00001c20 27 62 69 74 27 2c 20 6e 6f 77 0d 0a 3b 20 77 6f |'bit', now..; wo| 00001c30 72 6b 20 6f 75 74 20 77 68 65 74 68 65 72 20 74 |rk out whether t| 00001c40 68 65 20 27 62 69 74 27 20 69 73 20 66 75 6c 6c |he 'bit' is full| 00001c50 79 20 6f 6e 2d 73 63 72 65 65 6e 2c 20 6f 72 20 |y on-screen, or | 00001c60 77 68 65 74 68 65 72 20 77 65 20 6e 65 65 64 0d |whether we need.| 00001c70 0a 3b 20 74 6f 20 64 6f 20 73 6f 6d 65 20 58 20 |.; to do some X | 00001c80 63 6c 69 70 70 69 6e 67 0d 0a 3b 0d 0a 09 4c 44 |clipping..;...LD| 00001c90 52 09 52 33 2c 73 63 72 65 65 6e 5f 63 6c 69 70 |R.R3,screen_clip| 00001ca0 5f 6c 65 66 74 0d 0a 09 4c 44 52 09 52 34 2c 73 |_left...LDR.R4,s| 00001cb0 63 72 65 65 6e 5f 63 6c 69 70 5f 72 69 67 68 74 |creen_clip_right| 00001cc0 0d 0a 09 43 4d 50 09 52 31 2c 52 33 0d 0a 09 42 |...CMP.R1,R3...B| 00001cd0 4c 54 09 63 6c 69 70 5f 6c 65 66 74 0d 0a 09 43 |LT.clip_left...C| 00001ce0 4d 50 09 52 35 2c 52 34 0d 0a 09 42 47 54 09 63 |MP.R5,R4...BGT.c| 00001cf0 6c 69 70 5f 72 69 67 68 74 0d 0a 09 42 09 6e 6f |lip_right...B.no| 00001d00 5f 63 6c 69 70 70 69 6e 67 0d 0a 3b 0d 0a 3b 20 |_clipping..;..; | 00001d10 52 65 6c 65 76 61 6e 74 20 72 65 67 69 73 74 65 |Relevant registe| 00001d20 72 73 20 66 6f 72 20 58 20 63 6c 69 70 70 69 6e |rs for X clippin| 00001d30 67 20 2d 2d 20 70 61 79 20 61 74 74 65 6e 74 69 |g -- pay attenti| 00001d40 6f 6e 20 74 6f 20 74 68 69 73 0d 0a 3b 0d 0a 3b |on to this..;..;| 00001d50 20 52 31 20 20 3d 20 78 20 63 6f 2d 6f 72 64 69 | R1 = x co-ordi| 00001d60 6e 61 74 65 20 74 6f 20 73 74 61 72 74 20 70 6c |nate to start pl| 00001d70 6f 74 74 69 6e 67 20 28 63 6f 75 6c 64 20 62 65 |otting (could be| 00001d80 20 6f 66 66 20 73 63 72 65 65 6e 3f 29 0d 0a 3b | off screen?)..;| 00001d90 20 52 32 20 20 3d 20 79 20 63 6f 2d 6f 72 64 69 | R2 = y co-ordi| 00001da0 6e 61 74 65 20 74 6f 20 73 74 61 72 74 20 70 6c |nate to start pl| 00001db0 6f 74 74 69 6e 67 0d 0a 3b 20 52 33 20 20 3d 20 |otting..; R3 = | 00001dc0 66 69 72 73 74 20 78 20 70 69 78 65 6c 20 69 6e |first x pixel in| 00001dd0 20 77 69 6e 64 6f 77 0d 0a 3b 20 52 34 20 20 3d | window..; R4 =| 00001de0 20 6c 61 73 74 20 78 20 70 69 78 65 6c 20 69 6e | last x pixel in| 00001df0 20 77 69 6e 64 6f 77 0d 0a 3b 20 52 35 20 20 3d | window..; R5 =| 00001e00 20 78 20 63 6f 2d 6f 72 64 69 6e 61 74 65 20 61 | x co-ordinate a| 00001e10 66 74 65 72 20 70 6c 6f 74 20 28 6f 66 66 20 73 |fter plot (off s| 00001e20 63 72 65 65 6e 3f 29 0d 0a 3b 20 52 38 20 20 3d |creen?)..; R8 =| 00001e30 20 27 74 79 70 65 27 20 70 61 72 74 20 6f 66 20 | 'type' part of | 00001e40 74 79 70 65 20 77 6f 72 64 20 28 69 2e 65 2e 20 |type word (i.e. | 00001e50 74 74 29 0d 0a 3b 20 52 39 20 20 3d 20 6e 75 6d |tt)..; R9 = num| 00001e60 62 65 72 20 6f 66 20 62 79 74 65 73 20 28 69 2e |ber of bytes (i.| 00001e70 65 2e 20 64 64 64 64 29 0d 0a 3b 20 52 31 31 20 |e. dddd)..; R11 | 00001e80 3d 20 73 63 72 65 65 6e 20 61 64 64 72 65 73 73 |= screen address| 00001e90 20 74 6f 20 73 74 61 72 74 0d 0a 3b 20 52 31 32 | to start..; R12| 00001ea0 20 3d 20 73 74 61 72 74 20 61 64 64 72 65 73 73 | = start address| 00001eb0 20 6f 66 20 73 70 72 69 74 65 20 64 61 74 61 0d | of sprite data.| 00001ec0 0a 3b 0d 0a 63 6c 69 70 5f 6c 65 66 74 0d 0a 09 |.;..clip_left...| 00001ed0 43 4d 50 09 52 38 2c 23 32 0d 0a 09 42 4e 45 09 |CMP.R8,#2...BNE.| 00001ee0 63 6c 69 70 5f 6c 65 66 74 5f 62 69 74 5f 6f 6e |clip_left_bit_on| 00001ef0 0d 0a 09 41 44 44 09 52 31 31 2c 52 31 31 2c 52 |...ADD.R11,R11,R| 00001f00 39 0d 0a 09 4d 4f 56 09 52 31 2c 52 35 0d 0a 09 |9...MOV.R1,R5...| 00001f10 42 09 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 6e 65 |B.next_scan_line| 00001f20 5f 62 69 74 09 3b 20 44 65 61 6c 20 77 69 74 68 |_bit.; Deal with| 00001f30 20 6d 61 73 6b 73 20 62 79 20 6a 75 73 74 20 73 | masks by just s| 00001f40 68 69 66 74 69 6e 67 0d 0a 09 09 09 09 09 3b 20 |hifting.......; | 00001f50 74 68 65 20 72 65 6c 65 76 61 6e 74 20 70 6f 69 |the relevant poi| 00001f60 6e 74 65 72 73 20 6f 6e 0d 0a 63 6c 69 70 5f 6c |nters on..clip_l| 00001f70 65 66 74 5f 62 69 74 5f 6f 6e 0d 0a 09 43 4d 50 |eft_bit_on...CMP| 00001f80 09 52 35 2c 52 33 0d 0a 09 42 47 45 09 63 6c 69 |.R5,R3...BGE.cli| 00001f90 70 5f 6c 65 66 74 5f 6e 6f 74 5f 63 6f 6d 70 6c |p_left_not_compl| 00001fa0 65 74 65 6c 79 5f 6f 66 66 0d 0a 09 41 4e 44 09 |etely_off...AND.| 00001fb0 52 37 2c 52 31 31 2c 23 33 0d 0a 09 41 44 44 09 |R7,R11,#3...ADD.| 00001fc0 52 31 32 2c 52 31 32 2c 52 37 09 09 3b 20 50 75 |R12,R12,R7..; Pu| 00001fd0 73 68 20 52 31 32 20 61 6c 6f 6e 67 20 61 63 63 |sh R12 along acc| 00001fe0 6f 72 64 69 6e 67 20 74 6f 20 61 6c 69 67 6e 0d |ording to align.| 00001ff0 0a 09 41 44 44 09 52 31 32 2c 52 31 32 2c 52 39 |..ADD.R12,R12,R9| 00002000 0d 0a 09 41 44 44 09 52 31 31 2c 52 31 31 2c 52 |...ADD.R11,R11,R| 00002010 39 0d 0a 09 4d 4f 56 09 52 31 2c 52 35 0d 0a 09 |9...MOV.R1,R5...| 00002020 42 09 61 6c 69 67 6e 5f 72 31 32 5f 6e 6f 5f 72 |B.align_r12_no_r| 00002030 65 73 74 6f 72 65 0d 0a 63 6c 69 70 5f 6c 65 66 |estore..clip_lef| 00002040 74 5f 6e 6f 74 5f 63 6f 6d 70 6c 65 74 65 6c 79 |t_not_completely| 00002050 5f 6f 66 66 0d 0a 09 41 4e 44 09 52 37 2c 52 31 |_off...AND.R7,R1| 00002060 31 2c 23 33 0d 0a 09 41 44 44 09 52 31 32 2c 52 |1,#3...ADD.R12,R| 00002070 31 32 2c 52 37 09 09 3b 20 50 75 73 68 20 52 31 |12,R7..; Push R1| 00002080 32 20 61 6c 6f 6e 67 20 61 63 63 6f 72 64 69 6e |2 along accordin| 00002090 67 20 74 6f 20 61 6c 69 67 6e 0d 0a 09 53 55 42 |g to align...SUB| 000020a0 09 52 36 2c 52 33 2c 52 31 09 09 3b 20 52 36 20 |.R6,R3,R1..; R6 | 000020b0 3d 20 6e 6f 2e 20 6f 66 20 70 69 78 65 6c 73 20 |= no. of pixels | 000020c0 6f 66 66 20 6c 65 66 74 0d 0a 09 41 44 44 09 52 |off left...ADD.R| 000020d0 31 31 2c 52 31 31 2c 52 36 0d 0a 09 41 44 44 09 |11,R11,R6...ADD.| 000020e0 52 31 32 2c 52 31 32 2c 52 36 0d 0a 09 4d 4f 56 |R12,R12,R6...MOV| 000020f0 09 52 31 2c 52 35 0d 0a 09 53 55 42 09 52 39 2c |.R1,R5...SUB.R9,| 00002100 52 39 2c 52 36 09 09 3b 20 41 64 6a 75 73 74 20 |R9,R6..; Adjust | 00002110 73 74 61 72 74 20 2f 20 6e 6f 2e 20 6f 66 20 70 |start / no. of p| 00002120 69 78 65 6c 73 0d 0a 09 43 4d 50 09 52 35 2c 52 |ixels...CMP.R5,R| 00002130 34 09 09 09 3b 20 43 68 65 63 6b 20 66 6f 72 20 |4...; Check for | 00002140 63 6c 69 70 20 72 69 67 68 74 20 61 73 20 77 65 |clip right as we| 00002150 6c 6c 0d 0a 09 42 4c 45 09 73 74 61 72 74 5f 70 |ll...BLE.start_p| 00002160 6c 6f 74 5f 62 69 74 0d 0a 09 41 44 44 09 52 34 |lot_bit...ADD.R4| 00002170 2c 52 34 2c 23 31 09 09 3b 0d 0a 09 53 55 42 09 |,R4,#1..;...SUB.| 00002180 52 36 2c 52 35 2c 52 34 09 09 3b 20 43 6f 64 65 |R6,R5,R4..; Code| 00002190 20 63 6f 70 69 65 64 20 66 72 6f 6d 20 62 65 6c | copied from bel| 000021a0 6f 77 0d 0a 09 53 54 52 09 52 36 2c 63 6f 6d 70 |ow...STR.R6,comp| 000021b0 65 6e 73 61 74 65 5f 72 69 67 68 74 09 3b 0d 0a |ensate_right.;..| 000021c0 09 53 55 42 09 52 39 2c 52 39 2c 52 36 09 09 3b |.SUB.R9,R9,R6..;| 000021d0 0d 0a 09 42 09 73 74 61 72 74 5f 70 6c 6f 74 5f |...B.start_plot_| 000021e0 62 69 74 09 09 3b 0d 0a 0d 0a 63 6c 69 70 5f 72 |bit..;....clip_r| 000021f0 69 67 68 74 0d 0a 09 43 4d 50 09 52 38 2c 23 32 |ight...CMP.R8,#2| 00002200 0d 0a 09 42 45 51 09 6e 65 78 74 5f 73 63 61 6e |...BEQ.next_scan| 00002210 5f 6c 69 6e 65 09 09 3b 20 4d 61 73 6b 20 6f 66 |_line..; Mask of| 00002220 66 20 72 69 67 68 74 20 2d 3e 20 6e 65 78 74 20 |f right -> next | 00002230 6c 69 6e 65 0d 0a 09 41 44 44 09 52 34 2c 52 34 |line...ADD.R4,R4| 00002240 2c 23 31 09 09 3b 20 41 72 73 65 0d 0a 09 53 55 |,#1..; Arse...SU| 00002250 42 09 52 36 2c 52 35 2c 52 34 09 09 3b 20 52 36 |B.R6,R5,R4..; R6| 00002260 20 3d 20 6e 6f 2e 20 6f 66 20 70 69 78 65 6c 73 | = no. of pixels| 00002270 20 6f 66 66 20 72 69 67 68 74 0d 0a 09 53 54 52 | off right...STR| 00002280 09 52 36 2c 63 6f 6d 70 65 6e 73 61 74 65 5f 72 |.R6,compensate_r| 00002290 69 67 68 74 09 3b 20 43 6f 6d 70 65 6e 73 61 74 |ight.; Compensat| 000022a0 65 20 61 66 74 65 72 20 70 6c 6f 74 0d 0a 09 53 |e after plot...S| 000022b0 55 42 09 52 39 2c 52 39 2c 52 36 09 09 3b 20 43 |UB.R9,R9,R6..; C| 000022c0 6c 69 70 20 70 69 78 65 6c 73 20 6f 66 66 20 72 |lip pixels off r| 000022d0 69 67 68 74 0d 0a 09 4d 4f 56 09 52 31 2c 52 35 |ight...MOV.R1,R5| 000022e0 0d 0a 09 41 4e 44 09 52 33 2c 52 31 31 2c 23 33 |...AND.R3,R11,#3| 000022f0 0d 0a 09 41 44 44 09 52 31 32 2c 52 31 32 2c 52 |...ADD.R12,R12,R| 00002300 33 0d 0a 09 42 09 73 74 61 72 74 5f 70 6c 6f 74 |3...B.start_plot| 00002310 5f 62 69 74 0d 0a 0d 0a 6e 6f 5f 63 6c 69 70 70 |_bit....no_clipp| 00002320 69 6e 67 0d 0a 09 41 44 44 09 52 31 2c 52 31 2c |ing...ADD.R1,R1,| 00002330 52 39 09 09 3b 20 41 64 6a 75 73 74 20 58 0d 0a |R9..; Adjust X..| 00002340 09 43 4d 50 09 52 38 2c 23 32 0d 0a 09 41 44 44 |.CMP.R8,#2...ADD| 00002350 45 51 09 52 31 31 2c 52 31 31 2c 52 39 0d 0a 09 |EQ.R11,R11,R9...| 00002360 42 45 51 09 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 |BEQ.next_scan_li| 00002370 6e 65 5f 62 69 74 09 3b 20 53 6b 69 70 20 73 63 |ne_bit.; Skip sc| 00002380 72 65 65 6e 20 6d 65 6d 6f 72 79 20 69 66 20 69 |reen memory if i| 00002390 74 27 73 20 61 20 6d 61 73 6b 0d 0a 09 41 4e 44 |t's a mask...AND| 000023a0 09 52 33 2c 52 31 31 2c 23 33 09 09 3b 20 47 65 |.R3,R11,#3..; Ge| 000023b0 74 20 61 6c 69 67 6e 6d 65 6e 74 20 6f 66 20 73 |t alignment of s| 000023c0 63 72 65 65 6e 20 61 64 64 72 65 73 73 0d 0a 09 |creen address...| 000023d0 41 44 44 09 52 31 32 2c 52 31 32 2c 52 33 09 09 |ADD.R12,R12,R3..| 000023e0 3b 20 41 64 6a 75 73 74 20 73 74 61 72 74 20 6f |; Adjust start o| 000023f0 66 20 64 61 74 61 0d 0a 3b 0d 0a 3b 20 52 69 67 |f data..;..; Rig| 00002400 68 74 2c 20 68 65 72 65 20 69 73 20 77 68 65 72 |ht, here is wher| 00002410 65 20 77 65 20 63 61 6e 20 73 74 61 72 74 20 70 |e we can start p| 00002420 6c 6f 74 74 69 6e 67 21 0d 0a 3b 20 20 20 52 31 |lotting!..; R1| 00002430 32 20 3e 20 73 70 72 69 74 65 20 64 61 74 61 20 |2 > sprite data | 00002440 28 61 6c 69 67 6e 65 64 2c 20 73 6f 20 77 61 74 |(aligned, so wat| 00002450 63 68 20 66 6f 72 20 7a 65 72 6f 65 73 20 61 74 |ch for zeroes at| 00002460 20 73 74 61 72 74 29 0d 0a 3b 20 20 20 52 31 31 | start)..; R11| 00002470 20 3e 20 73 63 72 65 65 6e 20 6d 65 6d 6f 72 79 | > screen memory| 00002480 20 74 6f 20 73 74 61 72 74 20 28 61 64 6a 75 73 | to start (adjus| 00002490 74 65 64 20 66 6f 72 20 63 6c 69 70 70 69 6e 67 |ted for clipping| 000024a0 29 0d 0a 3b 20 20 20 52 39 20 20 3d 20 6e 75 6d |)..; R9 = num| 000024b0 62 65 72 20 6f 66 20 62 79 74 65 73 20 74 6f 20 |ber of bytes to | 000024c0 70 6c 6f 74 0d 0a 3b 0d 0a 73 74 61 72 74 5f 70 |plot..;..start_p| 000024d0 6c 6f 74 5f 62 69 74 0d 0a 09 53 54 4d 46 44 09 |lot_bit...STMFD.| 000024e0 52 31 33 21 2c 7b 52 30 2d 52 37 7d 09 09 3b 20 |R13!,{R0-R7}..; | 000024f0 4b 65 65 70 20 73 63 72 61 74 63 68 20 72 65 67 |Keep scratch reg| 00002500 69 73 74 65 72 73 0d 0a 09 09 09 09 09 3b 20 27 |isters.......; '| 00002510 63 6f 73 20 77 65 27 72 65 20 67 6f 69 6e 67 20 |cos we're going | 00002520 74 6f 20 6f 76 65 72 77 72 69 74 65 20 74 68 65 |to overwrite the| 00002530 6d 0d 0a 09 09 09 09 09 3b 20 77 69 74 68 20 6d |m.......; with m| 00002540 75 6c 74 69 70 6c 65 20 6c 6f 61 64 73 2f 73 74 |ultiple loads/st| 00002550 6f 72 65 73 0d 0a 3b 0d 0a 3b 20 50 6c 6f 74 20 |ores..;..; Plot | 00002560 30 2d 33 20 62 79 74 65 73 20 73 6f 20 77 65 20 |0-3 bytes so we | 00002570 73 74 61 72 74 20 6f 6e 20 61 20 77 6f 72 64 20 |start on a word | 00002580 62 6f 75 6e 64 61 72 79 0d 0a 3b 0d 0a 09 43 4d |boundary..;...CM| 00002590 50 09 52 39 2c 23 30 0d 0a 09 42 4c 45 09 61 6c |P.R9,#0...BLE.al| 000025a0 69 67 6e 5f 72 31 32 0d 0a 09 54 53 54 09 52 31 |ign_r12...TST.R1| 000025b0 31 2c 23 31 0d 0a 09 42 45 51 09 6e 6f 5f 61 6c |1,#1...BEQ.no_al| 000025c0 69 67 6e 5f 30 0d 0a 09 4c 44 52 42 09 52 30 2c |ign_0...LDRB.R0,| 000025d0 5b 52 31 32 5d 2c 23 31 0d 0a 09 53 54 52 42 09 |[R12],#1...STRB.| 000025e0 52 30 2c 5b 52 31 31 5d 2c 23 31 0d 0a 09 53 55 |R0,[R11],#1...SU| 000025f0 42 53 09 52 39 2c 52 39 2c 23 31 0d 0a 09 42 45 |BS.R9,R9,#1...BE| 00002600 51 09 61 6c 69 67 6e 5f 72 31 32 0d 0a 6e 6f 5f |Q.align_r12..no_| 00002610 61 6c 69 67 6e 5f 30 0d 0a 09 54 53 54 09 52 31 |align_0...TST.R1| 00002620 31 2c 23 32 0d 0a 09 42 45 51 09 6e 6f 5f 61 6c |1,#2...BEQ.no_al| 00002630 69 67 6e 5f 31 0d 0a 09 4c 44 52 42 09 52 30 2c |ign_1...LDRB.R0,| 00002640 5b 52 31 32 5d 2c 23 31 0d 0a 09 53 54 52 42 09 |[R12],#1...STRB.| 00002650 52 30 2c 5b 52 31 31 5d 2c 23 31 0d 0a 09 53 55 |R0,[R11],#1...SU| 00002660 42 53 09 52 39 2c 52 39 2c 23 31 0d 0a 09 42 45 |BS.R9,R9,#1...BE| 00002670 51 09 61 6c 69 67 6e 5f 72 31 32 0d 0a 09 4c 44 |Q.align_r12...LD| 00002680 52 42 09 52 30 2c 5b 52 31 32 5d 2c 23 31 0d 0a |RB.R0,[R12],#1..| 00002690 09 53 54 52 42 09 52 30 2c 5b 52 31 31 5d 2c 23 |.STRB.R0,[R11],#| 000026a0 31 0d 0a 09 53 55 42 53 09 52 39 2c 52 39 2c 23 |1...SUBS.R9,R9,#| 000026b0 31 0d 0a 09 42 45 51 09 61 6c 69 67 6e 5f 72 31 |1...BEQ.align_r1| 000026c0 32 0d 0a 6e 6f 5f 61 6c 69 67 6e 5f 31 0d 0a 0d |2..no_align_1...| 000026d0 0a 3b 0d 0a 3b 20 4e 6f 77 20 77 65 27 72 65 20 |.;..; Now we're | 000026e0 6f 6e 20 61 20 77 6f 72 64 20 62 6f 75 6e 64 61 |on a word bounda| 000026f0 72 79 2c 20 77 65 20 63 61 6e 20 73 74 61 72 74 |ry, we can start| 00002700 20 70 6c 6f 74 74 69 6e 67 20 62 69 67 20 63 68 | plotting big ch| 00002710 75 6e 6b 73 20 77 69 74 68 0d 0a 3b 20 4c 44 52 |unks with..; LDR| 00002720 20 61 6e 64 20 4c 44 4d 20 69 6e 73 74 72 75 63 | and LDM instruc| 00002730 74 69 6f 6e 73 0d 0a 3b 0d 0a 09 54 53 54 09 52 |tions..;...TST.R| 00002740 39 2c 23 32 5f 31 30 30 0d 0a 09 42 45 51 09 6e |9,#2_100...BEQ.n| 00002750 6f 5f 62 69 74 5f 32 0d 0a 09 4c 44 52 09 52 30 |o_bit_2...LDR.R0| 00002760 2c 5b 52 31 32 5d 2c 23 34 0d 0a 09 53 54 52 09 |,[R12],#4...STR.| 00002770 52 30 2c 5b 52 31 31 5d 2c 23 34 0d 0a 09 42 49 |R0,[R11],#4...BI| 00002780 43 53 09 52 30 2c 52 39 2c 23 32 5f 31 31 31 0d |CS.R0,R9,#2_111.| 00002790 0a 09 42 45 51 09 6e 6f 5f 62 69 74 5f 38 0d 0a |..BEQ.no_bit_8..| 000027a0 6e 6f 5f 62 69 74 5f 32 0d 0a 09 54 53 54 09 52 |no_bit_2...TST.R| 000027b0 39 2c 23 32 5f 31 30 30 30 0d 0a 09 42 45 51 09 |9,#2_1000...BEQ.| 000027c0 6e 6f 5f 62 69 74 5f 33 0d 0a 09 4c 44 4d 49 41 |no_bit_3...LDMIA| 000027d0 09 52 31 32 21 2c 7b 52 30 2d 52 31 7d 0d 0a 09 |.R12!,{R0-R1}...| 000027e0 53 54 4d 49 41 09 52 31 31 21 2c 7b 52 30 2d 52 |STMIA.R11!,{R0-R| 000027f0 31 7d 0d 0a 6e 6f 5f 62 69 74 5f 33 0d 0a 09 54 |1}..no_bit_3...T| 00002800 53 54 09 52 39 2c 23 32 5f 31 30 30 30 30 0d 0a |ST.R9,#2_10000..| 00002810 09 42 45 51 09 6e 6f 5f 62 69 74 5f 34 0d 0a 09 |.BEQ.no_bit_4...| 00002820 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 |LDMIA.R12!,{R0-R| 00002830 33 7d 0d 0a 09 53 54 4d 49 41 09 52 31 31 21 2c |3}...STMIA.R11!,| 00002840 7b 52 30 2d 52 33 7d 0d 0a 6e 6f 5f 62 69 74 5f |{R0-R3}..no_bit_| 00002850 34 0d 0a 09 54 53 54 09 52 39 2c 23 32 5f 31 30 |4...TST.R9,#2_10| 00002860 30 30 30 30 0d 0a 09 42 45 51 09 6e 6f 5f 62 69 |0000...BEQ.no_bi| 00002870 74 5f 35 0d 0a 09 4c 44 4d 49 41 09 52 31 32 21 |t_5...LDMIA.R12!| 00002880 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 4d 49 41 |,{R0-R7}...STMIA| 00002890 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d 0d 0a 6e |.R11!,{R0-R7}..n| 000028a0 6f 5f 62 69 74 5f 35 0d 0a 09 54 53 54 09 52 39 |o_bit_5...TST.R9| 000028b0 2c 23 32 5f 31 30 30 30 30 30 30 0d 0a 09 42 45 |,#2_1000000...BE| 000028c0 51 09 6e 6f 5f 62 69 74 5f 36 0d 0a 09 4c 44 4d |Q.no_bit_6...LDM| 000028d0 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 37 7d 0d |IA.R12!,{R0-R7}.| 000028e0 0a 09 53 54 4d 49 41 09 52 31 31 21 2c 7b 52 30 |..STMIA.R11!,{R0| 000028f0 2d 52 37 7d 0d 0a 09 4c 44 4d 49 41 09 52 31 32 |-R7}...LDMIA.R12| 00002900 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 4d 49 |!,{R0-R7}...STMI| 00002910 41 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d 0d 0a |A.R11!,{R0-R7}..| 00002920 6e 6f 5f 62 69 74 5f 36 0d 0a 09 54 53 54 09 52 |no_bit_6...TST.R| 00002930 39 2c 23 32 5f 31 30 30 30 30 30 30 30 0d 0a 09 |9,#2_10000000...| 00002940 42 45 51 09 6e 6f 5f 62 69 74 5f 37 0d 0a 09 4c |BEQ.no_bit_7...L| 00002950 44 4d 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 37 |DMIA.R12!,{R0-R7| 00002960 7d 0d 0a 09 53 54 4d 49 41 09 52 31 31 21 2c 7b |}...STMIA.R11!,{| 00002970 52 30 2d 52 37 7d 0d 0a 09 4c 44 4d 49 41 09 52 |R0-R7}...LDMIA.R| 00002980 31 32 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 |12!,{R0-R7}...ST| 00002990 4d 49 41 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d |MIA.R11!,{R0-R7}| 000029a0 0d 0a 09 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 |...LDMIA.R12!,{R| 000029b0 30 2d 52 37 7d 0d 0a 09 53 54 4d 49 41 09 52 31 |0-R7}...STMIA.R1| 000029c0 31 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 4c 44 4d |1!,{R0-R7}...LDM| 000029d0 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 37 7d 0d |IA.R12!,{R0-R7}.| 000029e0 0a 09 53 54 4d 49 41 09 52 31 31 21 2c 7b 52 30 |..STMIA.R11!,{R0| 000029f0 2d 52 37 7d 0d 0a 6e 6f 5f 62 69 74 5f 37 0d 0a |-R7}..no_bit_7..| 00002a00 09 54 53 54 09 52 39 2c 23 32 5f 31 30 30 30 30 |.TST.R9,#2_10000| 00002a10 30 30 30 30 0d 0a 09 42 45 51 09 6e 6f 5f 62 69 |0000...BEQ.no_bi| 00002a20 74 5f 38 0d 0a 09 4c 44 4d 49 41 09 52 31 32 21 |t_8...LDMIA.R12!| 00002a30 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 4d 49 41 |,{R0-R7}...STMIA| 00002a40 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 |.R11!,{R0-R7}...| 00002a50 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 |LDMIA.R12!,{R0-R| 00002a60 37 7d 0d 0a 09 53 54 4d 49 41 09 52 31 31 21 2c |7}...STMIA.R11!,| 00002a70 7b 52 30 2d 52 37 7d 0d 0a 09 4c 44 4d 49 41 09 |{R0-R7}...LDMIA.| 00002a80 52 31 32 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 |R12!,{R0-R7}...S| 00002a90 54 4d 49 41 09 52 31 31 21 2c 7b 52 30 2d 52 37 |TMIA.R11!,{R0-R7| 00002aa0 7d 0d 0a 09 4c 44 4d 49 41 09 52 31 32 21 2c 7b |}...LDMIA.R12!,{| 00002ab0 52 30 2d 52 37 7d 0d 0a 09 53 54 4d 49 41 09 52 |R0-R7}...STMIA.R| 00002ac0 31 31 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 4c 44 |11!,{R0-R7}...LD| 00002ad0 4d 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 37 7d |MIA.R12!,{R0-R7}| 00002ae0 0d 0a 09 53 54 4d 49 41 09 52 31 31 21 2c 7b 52 |...STMIA.R11!,{R| 00002af0 30 2d 52 37 7d 0d 0a 09 4c 44 4d 49 41 09 52 31 |0-R7}...LDMIA.R1| 00002b00 32 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 4d |2!,{R0-R7}...STM| 00002b10 49 41 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d 0d |IA.R11!,{R0-R7}.| 00002b20 0a 09 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 30 |..LDMIA.R12!,{R0| 00002b30 2d 52 37 7d 0d 0a 09 53 54 4d 49 41 09 52 31 31 |-R7}...STMIA.R11| 00002b40 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 4c 44 4d 49 |!,{R0-R7}...LDMI| 00002b50 41 09 52 31 32 21 2c 7b 52 30 2d 52 37 7d 0d 0a |A.R12!,{R0-R7}..| 00002b60 09 53 54 4d 49 41 09 52 31 31 21 2c 7b 52 30 2d |.STMIA.R11!,{R0-| 00002b70 52 37 7d 0d 0a 6e 6f 5f 62 69 74 5f 38 0d 0a 3b |R7}..no_bit_8..;| 00002b80 0d 0a 3b 20 4e 6f 77 20 77 65 20 73 68 6f 75 6c |..; Now we shoul| 00002b90 64 20 68 61 76 65 20 70 6c 6f 74 74 65 64 20 61 |d have plotted a| 00002ba0 6c 6c 20 62 75 74 20 74 68 65 20 6c 61 73 74 20 |ll but the last | 00002bb0 30 2d 33 20 62 79 74 65 73 0d 0a 3b 0d 0a 09 54 |0-3 bytes..;...T| 00002bc0 53 54 09 52 39 2c 23 32 5f 31 0d 0a 09 42 45 51 |ST.R9,#2_1...BEQ| 00002bd0 09 6e 6f 5f 62 69 74 5f 30 0d 0a 09 4c 44 52 42 |.no_bit_0...LDRB| 00002be0 09 52 30 2c 5b 52 31 32 5d 2c 23 31 0d 0a 09 53 |.R0,[R12],#1...S| 00002bf0 54 52 42 09 52 30 2c 5b 52 31 31 5d 2c 23 31 0d |TRB.R0,[R11],#1.| 00002c00 0a 6e 6f 5f 62 69 74 5f 30 0d 0a 09 54 53 54 09 |.no_bit_0...TST.| 00002c10 52 39 2c 23 32 5f 31 30 0d 0a 09 42 45 51 09 6e |R9,#2_10...BEQ.n| 00002c20 6f 5f 62 69 74 5f 31 0d 0a 09 4c 44 52 42 09 52 |o_bit_1...LDRB.R| 00002c30 30 2c 5b 52 31 32 5d 2c 23 31 0d 0a 09 53 54 52 |0,[R12],#1...STR| 00002c40 42 09 52 30 2c 5b 52 31 31 5d 2c 23 31 0d 0a 09 |B.R0,[R11],#1...| 00002c50 4c 44 52 42 09 52 30 2c 5b 52 31 32 5d 2c 23 31 |LDRB.R0,[R12],#1| 00002c60 0d 0a 09 53 54 52 42 09 52 30 2c 5b 52 31 31 5d |...STRB.R0,[R11]| 00002c70 2c 23 31 0d 0a 6e 6f 5f 62 69 74 5f 31 0d 0a 3b |,#1..no_bit_1..;| 00002c80 0d 0a 3b 20 4e 6f 77 20 77 65 20 6e 65 65 64 20 |..; Now we need | 00002c90 74 6f 20 61 6c 69 67 6e 20 52 31 32 20 73 6f 20 |to align R12 so | 00002ca0 74 68 61 74 20 69 74 20 70 6f 69 6e 74 73 20 74 |that it points t| 00002cb0 6f 20 74 68 65 20 6e 65 78 74 20 27 74 79 70 65 |o the next 'type| 00002cc0 27 20 77 6f 72 64 2c 0d 0a 3b 20 73 69 6e 63 65 |' word,..; since| 00002cd0 20 69 74 20 63 6f 75 6c 64 20 62 65 20 73 74 72 | it could be str| 00002ce0 61 67 67 6c 69 6e 67 20 61 74 20 61 20 6e 6f 6e |aggling at a non| 00002cf0 20 77 6f 72 64 2d 61 6c 69 67 6e 65 64 20 70 6f | word-aligned po| 00002d00 73 69 74 69 6f 6e 2e 0d 0a 3b 0d 0a 61 6c 69 67 |sition...;..alig| 00002d10 6e 5f 72 31 32 0d 0a 09 4c 44 4d 46 44 09 52 31 |n_r12...LDMFD.R1| 00002d20 33 21 2c 7b 52 30 2d 52 37 7d 09 09 3b 20 52 65 |3!,{R0-R7}..; Re| 00002d30 73 74 6f 72 65 20 73 63 72 61 74 63 68 20 72 65 |store scratch re| 00002d40 67 69 73 74 65 72 73 0d 0a 61 6c 69 67 6e 5f 72 |gisters..align_r| 00002d50 31 32 5f 6e 6f 5f 72 65 73 74 6f 72 65 0d 0a 09 |12_no_restore...| 00002d60 4c 44 52 09 52 33 2c 63 6f 6d 70 65 6e 73 61 74 |LDR.R3,compensat| 00002d70 65 5f 72 69 67 68 74 0d 0a 09 41 44 44 09 52 31 |e_right...ADD.R1| 00002d80 32 2c 52 31 32 2c 52 33 0d 0a 09 4d 4f 56 09 52 |2,R12,R3...MOV.R| 00002d90 33 2c 23 30 0d 0a 09 53 54 52 09 52 33 2c 63 6f |3,#0...STR.R3,co| 00002da0 6d 70 65 6e 73 61 74 65 5f 72 69 67 68 74 0d 0a |mpensate_right..| 00002db0 09 41 44 44 09 52 31 32 2c 52 31 32 2c 23 33 0d |.ADD.R12,R12,#3.| 00002dc0 0a 09 42 49 43 09 52 31 32 2c 52 31 32 2c 23 33 |..BIC.R12,R12,#3| 00002dd0 0d 0a 6e 6f 5f 61 6c 69 67 6e 0d 0a 09 42 09 6e |..no_align...B.n| 00002de0 65 78 74 5f 73 63 61 6e 5f 6c 69 6e 65 5f 62 69 |ext_scan_line_bi| 00002df0 74 0d 0a 66 69 6e 69 73 68 65 64 5f 70 6c 6f 74 |t..finished_plot| 00002e00 0d 0a 09 4c 44 4d 46 44 09 52 31 33 21 2c 7b 52 |...LDMFD.R13!,{R| 00002e10 30 2d 52 31 32 2c 50 43 7d 5e 0d 0a 3b 0d 0a 3b |0-R12,PC}^..;..;| 00002e20 20 54 68 69 73 20 73 68 6f 75 6c 64 20 6e 65 76 | This should nev| 00002e30 65 72 20 68 61 70 70 65 6e 20 3a 2d 29 0d 0a 3b |er happen :-)..;| 00002e40 0d 0a 75 68 5f 6f 68 0d 0a 09 41 44 52 09 52 30 |..uh_oh...ADR.R0| 00002e50 2c 65 72 72 6f 72 0d 0a 09 53 57 49 09 26 32 42 |,error...SWI.&2B| 00002e60 20 3b 20 4f 53 5f 47 65 6e 65 72 61 74 65 45 72 | ; OS_GenerateEr| 00002e70 72 6f 72 0d 0a 0d 0a 65 72 72 6f 72 09 26 20 30 |ror....error.& 0| 00002e80 0d 0a 09 44 43 42 20 22 54 79 70 65 20 77 6f 72 |...DCB "Type wor| 00002e90 64 20 6f 75 74 20 6f 66 20 72 61 6e 67 65 20 28 |d out of range (| 00002ea0 30 2d 32 29 22 2c 30 0d 0a 09 41 4c 49 47 4e 0d |0-2)",0...ALIGN.| 00002eb0 0a 0d 0a 6c 61 73 74 5f 79 09 09 09 26 20 30 0d |...last_y...& 0.| 00002ec0 0a 66 69 72 73 74 5f 78 09 09 09 26 20 30 0d 0a |.first_x...& 0..| 00002ed0 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 6e 65 5f 61 |next_scan_line_a| 00002ee0 64 64 72 65 73 73 09 26 20 30 0d 0a 6e 65 78 74 |ddress.& 0..next| 00002ef0 5f 73 63 61 6e 5f 6c 69 6e 65 5f 70 74 72 09 26 |_scan_line_ptr.&| 00002f00 20 30 0d 0a 63 6f 6d 70 65 6e 73 61 74 65 5f 72 | 0..compensate_r| 00002f10 69 67 68 74 09 26 20 30 0d 0a 0d 0a 20 45 4e 44 |ight.& 0.... END| 00002f20 0d 0a |..| 00002f22