Home » Archimedes archive » Acorn User » AU 1996-12 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 1996-12 B.adf » Features |
Filename: | Arcade/!Popcorn/s/Plotters |
Read OK: | ✔ |
File size: | 2F75 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
; Sprite plotting and screen routines ; Matthew Bloch, 1996 ; ; A few routines for reading screen information, swapping the screen ; banks and plotting sprites with arbitrary clipping windows ; ; N.B. All co-ordinates are specified with (0,0) in the top-left, ; where going right & down is positive. ; 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 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,#1 STR R1,screen_number SWI 6 ; OS_Byte MOV R0,#113 MOV R1,#2 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 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 BGE Popcorn_ClearScreen_loop ADD R14,R14,#48 TST R14,#32 STMEQIA R12!,{R0-R7} ; Then carry on in decreasing powers of two TST R14,#16 STMEQIA R12!,{R0-R3} TST R4,#8 STMEQIA R12!,{R0-R1} TST R4,#4 STREQ R0,[R12],#4 TST R4,#2 STREQB R0,[R12],#1 STREQB R0,[R12],#1 TST R4,#1 STREQB 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 BGE Popcorn_PlotBackdrop_loop ADD R14,R14,#44 TST R14,#32 LDMEQIA R11!,{R0-R7} STMEQIA R12!,{R0-R7} TST R14,#16 LDMEQIA R11!,{R0-R3} STMEQIA R12!,{R0-R3} TST R4,#8 LDMEQIA R11!,{R0-R1} STMEQIA R12!,{R0-R1} TST R4,#4 LDREQ R0,[R11],#4 STREQ R0,[R12],#4 TST R4,#2 LDREQB R0,[R11],#1 STREQB R0,[R12],#1 LDREQB R0,[R11],#1 STREQB R0,[R12],#1 TST R4,#1 LDREQB R0,[R11],#1 STREQB 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) ; 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 3b 20 53 70 72 69 74 65 20 70 6c 6f 74 74 69 6e |; Sprite plottin| 00000010 67 20 61 6e 64 20 73 63 72 65 65 6e 20 72 6f 75 |g and screen rou| 00000020 74 69 6e 65 73 0d 0a 3b 20 4d 61 74 74 68 65 77 |tines..; Matthew| 00000030 20 42 6c 6f 63 68 2c 20 31 39 39 36 0d 0a 3b 0d | Bloch, 1996..;.| 00000040 0a 3b 20 41 20 66 65 77 20 72 6f 75 74 69 6e 65 |.; A few routine| 00000050 73 20 66 6f 72 20 72 65 61 64 69 6e 67 20 73 63 |s for reading sc| 00000060 72 65 65 6e 20 69 6e 66 6f 72 6d 61 74 69 6f 6e |reen information| 00000070 2c 20 73 77 61 70 70 69 6e 67 20 74 68 65 20 73 |, swapping the s| 00000080 63 72 65 65 6e 0d 0a 3b 20 62 61 6e 6b 73 20 61 |creen..; banks a| 00000090 6e 64 20 70 6c 6f 74 74 69 6e 67 20 73 70 72 69 |nd plotting spri| 000000a0 74 65 73 20 77 69 74 68 20 61 72 62 69 74 72 61 |tes with arbitra| 000000b0 72 79 20 63 6c 69 70 70 69 6e 67 20 77 69 6e 64 |ry clipping wind| 000000c0 6f 77 73 0d 0a 3b 0d 0a 3b 20 4e 2e 42 2e 20 41 |ows..;..; N.B. A| 000000d0 6c 6c 20 63 6f 2d 6f 72 64 69 6e 61 74 65 73 20 |ll co-ordinates | 000000e0 61 72 65 20 73 70 65 63 69 66 69 65 64 20 77 69 |are specified wi| 000000f0 74 68 20 28 30 2c 30 29 20 69 6e 20 74 68 65 20 |th (0,0) in the | 00000100 74 6f 70 2d 6c 65 66 74 2c 0d 0a 3b 20 20 20 20 |top-left,..; | 00000110 20 20 77 68 65 72 65 20 67 6f 69 6e 67 20 72 69 | where going ri| 00000120 67 68 74 20 26 20 64 6f 77 6e 20 69 73 20 70 6f |ght & down is po| 00000130 73 69 74 69 76 65 2e 0d 0a 3b 0d 0a 0d 0a 20 41 |sitive...;.... A| 00000140 52 45 41 09 70 6c 6f 74 74 65 72 73 2c 20 43 4f |REA.plotters, CO| 00000150 44 45 20 3b 20 4e 6f 74 20 73 74 72 69 63 74 6c |DE ; Not strictl| 00000160 79 20 74 72 75 65 2c 20 62 75 74 20 77 65 20 77 |y true, but we w| 00000170 61 6e 74 20 74 68 65 20 69 6d 70 6f 72 74 61 6e |ant the importan| 00000180 74 0d 0a 09 09 20 20 20 20 20 20 20 3b 20 76 61 |t.... ; va| 00000190 72 69 61 62 6c 65 73 20 6b 65 70 74 20 74 6f 67 |riables kept tog| 000001a0 65 74 68 65 72 20 77 69 74 68 20 74 68 65 20 63 |ether with the c| 000001b0 6f 64 65 20 73 6f 20 77 65 0d 0a 09 09 20 20 20 |ode so we.... | 000001c0 20 20 20 20 3b 20 64 6f 6e 27 74 20 68 61 76 65 | ; don't have| 000001d0 20 74 6f 20 75 73 65 20 6c 6f 6e 67 20 41 44 52 | to use long ADR| 000001e0 73 20 6f 72 20 4c 44 52 73 0d 0a 0d 0a 20 47 45 |s or LDRs.... GE| 000001f0 54 09 48 64 72 2e 4d 61 63 72 6f 73 0d 0a 0d 0a |T.Hdr.Macros....| 00000200 20 45 58 50 4f 52 54 09 50 6f 70 63 6f 72 6e 5f | EXPORT.Popcorn_| 00000210 52 65 61 64 53 63 72 65 65 6e 44 65 74 61 69 6c |ReadScreenDetail| 00000220 73 2c 20 50 6f 70 63 6f 72 6e 5f 53 77 61 70 42 |s, Popcorn_SwapB| 00000230 61 6e 6b 73 0d 0a 20 45 58 50 4f 52 54 20 50 6f |anks.. EXPORT Po| 00000240 70 63 6f 72 6e 5f 50 6c 6f 74 53 70 72 69 74 65 |pcorn_PlotSprite| 00000250 2c 20 50 6f 70 63 6f 72 6e 5f 50 6c 6f 74 42 61 |, Popcorn_PlotBa| 00000260 63 6b 64 72 6f 70 0d 0a 20 45 58 50 4f 52 54 20 |ckdrop.. EXPORT | 00000270 50 6f 70 63 6f 72 6e 5f 53 65 74 43 6c 69 70 57 |Popcorn_SetClipW| 00000280 69 6e 64 6f 77 2c 20 50 6f 70 63 6f 72 6e 5f 43 |indow, Popcorn_C| 00000290 6c 65 61 72 53 63 72 65 65 6e 0d 0a 0d 0a 20 45 |learScreen.... E| 000002a0 58 50 4f 52 54 20 70 6c 6f 74 5f 77 69 6e 64 6f |XPORT plot_windo| 000002b0 77 0d 0a 0d 0a 69 6e 5f 62 75 66 66 65 72 31 09 |w....in_buffer1.| 000002c0 26 20 31 34 38 2c 31 34 39 2c 31 31 2c 31 32 2c |& 148,149,11,12,| 000002d0 37 2c 34 2c 35 2c 2d 31 0d 0a 73 63 72 65 65 6e |7,4,5,-1..screen| 000002e0 5f 6e 75 6d 62 65 72 09 26 20 30 20 3b 20 30 20 |_number.& 0 ; 0 | 000002f0 6f 72 20 31 20 64 65 70 65 6e 64 69 6e 67 20 6f |or 1 depending o| 00000300 6e 20 61 6e 69 6d 61 74 69 6f 6e 20 66 72 61 6d |n animation fram| 00000310 65 0d 0a 73 63 72 65 65 6e 5f 73 74 61 72 74 09 |e..screen_start.| 00000320 26 20 30 20 3b 20 42 61 73 65 20 6f 66 20 73 63 |& 0 ; Base of sc| 00000330 72 65 65 6e 20 62 61 6e 6b 20 74 6f 20 73 74 61 |reen bank to sta| 00000340 72 74 20 70 6c 6f 74 74 69 6e 67 20 6f 6e 0d 0a |rt plotting on..| 00000350 73 63 72 65 65 6e 5f 72 65 73 65 72 76 65 09 26 |screen_reserve.&| 00000360 20 30 20 3b 20 42 61 73 65 20 6f 66 20 73 63 72 | 0 ; Base of scr| 00000370 65 65 6e 20 62 61 6e 6b 20 62 65 69 6e 67 20 64 |een bank being d| 00000380 69 73 70 6c 61 79 65 64 0d 0a 73 63 72 65 65 6e |isplayed..screen| 00000390 5f 6c 61 73 74 78 70 69 78 09 26 20 30 20 3b 20 |_lastxpix.& 0 ; | 000003a0 4e 6f 2e 20 6f 66 20 63 6f 6c 75 6d 6e 73 20 6f |No. of columns o| 000003b0 6e 20 73 63 72 65 65 6e 0d 0a 73 63 72 65 65 6e |n screen..screen| 000003c0 5f 6c 61 73 74 79 70 69 78 20 26 20 30 20 3b 20 |_lastypix & 0 ; | 000003d0 4e 6f 2e 20 6f 66 20 72 6f 77 73 20 6f 6e 20 73 |No. of rows on s| 000003e0 63 72 65 65 6e 0d 0a 73 63 72 65 65 6e 5f 73 69 |creen..screen_si| 000003f0 7a 65 09 26 20 30 20 3b 20 53 69 7a 65 20 6f 66 |ze.& 0 ; Size of| 00000400 20 6f 6e 65 20 73 63 72 65 65 6e 20 62 61 6e 6b | one screen bank| 00000410 0d 0a 70 6c 6f 74 5f 77 69 6e 64 6f 77 0d 0a 73 |..plot_window..s| 00000420 63 72 65 65 6e 5f 63 6c 69 70 5f 6c 65 66 74 09 |creen_clip_left.| 00000430 26 20 30 0d 0a 73 63 72 65 65 6e 5f 63 6c 69 70 |& 0..screen_clip| 00000440 5f 74 6f 70 09 09 26 20 30 0d 0a 73 63 72 65 65 |_top..& 0..scree| 00000450 6e 5f 63 6c 69 70 5f 72 69 67 68 74 09 26 20 30 |n_clip_right.& 0| 00000460 0d 0a 73 63 72 65 65 6e 5f 63 6c 69 70 5f 62 6f |..screen_clip_bo| 00000470 74 74 6f 6d 20 09 26 20 30 0d 0a 0d 0a 50 6f 70 |ttom .& 0....Pop| 00000480 63 6f 72 6e 5f 52 65 61 64 53 63 72 65 65 6e 44 |corn_ReadScreenD| 00000490 65 74 61 69 6c 73 0d 0a 3b 0d 0a 3b 20 53 65 6c |etails..;..; Sel| 000004a0 66 2d 65 78 70 6c 61 6e 61 74 6f 72 79 20 72 6f |f-explanatory ro| 000004b0 75 74 69 6e 65 20 77 68 69 63 68 20 72 65 61 64 |utine which read| 000004c0 73 20 69 6e 20 61 20 66 65 77 20 56 44 55 20 76 |s in a few VDU v| 000004d0 61 72 69 61 62 6c 65 73 20 61 6e 64 0d 0a 3b 20 |ariables and..; | 000004e0 73 74 6f 72 65 73 20 74 68 65 6d 20 69 6e 74 65 |stores them inte| 000004f0 72 6e 61 6c 6c 79 20 66 6f 72 20 74 68 65 20 73 |rnally for the s| 00000500 70 72 69 74 65 20 70 6c 6f 74 74 65 72 20 61 6e |prite plotter an| 00000510 64 20 6f 74 68 65 72 20 64 69 73 70 6c 61 79 0d |d other display.| 00000520 0a 3b 20 72 6f 75 74 69 6e 65 73 0d 0a 3b 0d 0a |.; routines..;..| 00000530 09 53 54 4d 46 44 09 52 31 33 21 2c 7b 52 30 2d |.STMFD.R13!,{R0-| 00000540 52 32 2c 52 31 34 7d 0d 0a 09 4d 4f 56 09 52 30 |R2,R14}...MOV.R0| 00000550 2c 23 31 31 32 0d 0a 09 4d 4f 56 09 52 31 2c 23 |,#112...MOV.R1,#| 00000560 31 0d 0a 09 53 54 52 09 52 31 2c 73 63 72 65 65 |1...STR.R1,scree| 00000570 6e 5f 6e 75 6d 62 65 72 0d 0a 09 53 57 49 09 36 |n_number...SWI.6| 00000580 20 3b 20 4f 53 5f 42 79 74 65 0d 0a 09 4d 4f 56 | ; OS_Byte...MOV| 00000590 09 52 30 2c 23 31 31 33 0d 0a 09 4d 4f 56 09 52 |.R0,#113...MOV.R| 000005a0 31 2c 23 32 0d 0a 09 53 57 49 09 36 20 3b 20 4f |1,#2...SWI.6 ; O| 000005b0 53 5f 42 79 74 65 0d 0a 09 41 44 52 09 52 30 2c |S_Byte...ADR.R0,| 000005c0 69 6e 5f 62 75 66 66 65 72 31 0d 0a 09 41 44 52 |in_buffer1...ADR| 000005d0 09 52 31 2c 73 63 72 65 65 6e 5f 73 74 61 72 74 |.R1,screen_start| 000005e0 0d 0a 09 53 57 49 09 26 33 31 20 3b 20 4f 53 5f |...SWI.&31 ; OS_| 000005f0 52 65 61 64 56 64 75 56 61 72 69 61 62 6c 65 73 |ReadVduVariables| 00000600 0d 0a 09 4c 44 52 09 52 31 2c 73 63 72 65 65 6e |...LDR.R1,screen| 00000610 5f 6c 61 73 74 78 70 69 78 0d 0a 09 4c 44 52 09 |_lastxpix...LDR.| 00000620 52 32 2c 73 63 72 65 65 6e 5f 6c 61 73 74 79 70 |R2,screen_lastyp| 00000630 69 78 0d 0a 09 53 54 52 09 52 31 2c 73 63 72 65 |ix...STR.R1,scre| 00000640 65 6e 5f 63 6c 69 70 5f 72 69 67 68 74 0d 0a 09 |en_clip_right...| 00000650 53 54 52 09 52 32 2c 73 63 72 65 65 6e 5f 63 6c |STR.R2,screen_cl| 00000660 69 70 5f 62 6f 74 74 6f 6d 0d 0a 09 4d 4f 56 09 |ip_bottom...MOV.| 00000670 52 32 2c 23 30 0d 0a 09 53 54 52 09 52 32 2c 73 |R2,#0...STR.R2,s| 00000680 63 72 65 65 6e 5f 63 6c 69 70 5f 74 6f 70 0d 0a |creen_clip_top..| 00000690 09 53 54 52 09 52 32 2c 73 63 72 65 65 6e 5f 63 |.STR.R2,screen_c| 000006a0 6c 69 70 5f 6c 65 66 74 0d 0a 09 4c 44 4d 46 44 |lip_left...LDMFD| 000006b0 09 52 31 33 21 2c 7b 52 30 2d 52 32 2c 50 43 7d |.R13!,{R0-R2,PC}| 000006c0 5e 0d 0a 0d 0a 50 6f 70 63 6f 72 6e 5f 53 77 61 |^....Popcorn_Swa| 000006d0 70 42 61 6e 6b 73 0d 0a 3b 0d 0a 3b 20 41 6e 6f |pBanks..;..; Ano| 000006e0 74 68 65 72 20 66 61 69 72 6c 79 20 73 69 6d 70 |ther fairly simp| 000006f0 6c 65 20 72 6f 75 74 69 6e 65 2e 2e 2e 0d 0a 3b |le routine.....;| 00000700 0d 0a 09 53 54 4d 46 44 09 52 31 33 21 2c 7b 52 |...STMFD.R13!,{R| 00000710 30 2d 52 32 2c 52 31 34 7d 0d 0a 09 4c 44 52 09 |0-R2,R14}...LDR.| 00000720 52 30 2c 73 63 72 65 65 6e 5f 73 74 61 72 74 0d |R0,screen_start.| 00000730 0a 09 4c 44 52 09 52 31 2c 73 63 72 65 65 6e 5f |..LDR.R1,screen_| 00000740 72 65 73 65 72 76 65 0d 0a 09 53 54 52 09 52 31 |reserve...STR.R1| 00000750 2c 73 63 72 65 65 6e 5f 73 74 61 72 74 0d 0a 09 |,screen_start...| 00000760 53 54 52 09 52 30 2c 73 63 72 65 65 6e 5f 72 65 |STR.R0,screen_re| 00000770 73 65 72 76 65 0d 0a 0d 0a 09 4c 44 52 09 52 31 |serve.....LDR.R1| 00000780 2c 73 63 72 65 65 6e 5f 6e 75 6d 62 65 72 0d 0a |,screen_number..| 00000790 09 52 53 42 09 52 31 2c 52 31 2c 23 33 0d 0a 09 |.RSB.R1,R1,#3...| 000007a0 53 54 52 09 52 31 2c 73 63 72 65 65 6e 5f 6e 75 |STR.R1,screen_nu| 000007b0 6d 62 65 72 0d 0a 09 4d 4f 56 09 52 30 2c 23 31 |mber...MOV.R0,#1| 000007c0 31 32 0d 0a 09 53 57 49 09 36 20 3b 20 4f 53 5f |12...SWI.6 ; OS_| 000007d0 42 79 74 65 0d 0a 09 4d 4f 56 09 52 30 2c 23 31 |Byte...MOV.R0,#1| 000007e0 31 33 0d 0a 09 53 57 49 09 36 20 3b 20 4f 53 5f |13...SWI.6 ; OS_| 000007f0 42 79 74 65 0d 0a 09 4c 44 4d 46 44 09 52 31 33 |Byte...LDMFD.R13| 00000800 21 2c 7b 52 30 2d 52 32 2c 50 43 7d 5e 0d 0a 0d |!,{R0-R2,PC}^...| 00000810 0a 50 6f 70 63 6f 72 6e 5f 43 6c 65 61 72 53 63 |.Popcorn_ClearSc| 00000820 72 65 65 6e 0d 0a 3b 0d 0a 3b 20 46 69 6c 6c 73 |reen..;..; Fills| 00000830 20 74 68 65 20 73 63 72 65 65 6e 20 6d 65 6d 6f | the screen memo| 00000840 72 79 20 61 73 20 71 75 69 63 6b 6c 79 20 61 73 |ry as quickly as| 00000850 20 70 6f 73 73 69 62 6c 65 20 77 69 74 68 20 61 | possible with a| 00000860 20 70 61 72 74 69 63 75 6c 61 72 0d 0a 3b 20 62 | particular..; b| 00000870 79 74 65 2c 20 73 70 65 63 69 66 69 65 64 20 69 |yte, specified i| 00000880 6e 20 52 30 2e 20 20 49 74 27 73 20 66 61 73 74 |n R0. It's fast| 00000890 20 61 6e 79 77 61 79 2e 0d 0a 3b 0d 0a 09 53 54 | anyway...;...ST| 000008a0 4d 46 44 09 52 31 33 21 2c 7b 52 30 2d 52 31 32 |MFD.R13!,{R0-R12| 000008b0 2c 52 31 34 7d 0d 0a 09 41 4e 44 09 52 30 2c 52 |,R14}...AND.R0,R| 000008c0 30 2c 52 30 2c 4c 53 4c 23 38 0d 0a 09 41 4e 44 |0,R0,LSL#8...AND| 000008d0 09 52 30 2c 52 30 2c 52 30 2c 4c 53 4c 23 31 36 |.R0,R0,R0,LSL#16| 000008e0 0d 0a 09 4d 4f 56 09 52 31 2c 52 30 0d 0a 09 4d |...MOV.R1,R0...M| 000008f0 4f 56 09 52 32 2c 52 30 0d 0a 09 4d 4f 56 09 52 |OV.R2,R0...MOV.R| 00000900 33 2c 52 30 0d 0a 09 4d 4f 56 09 52 34 2c 52 30 |3,R0...MOV.R4,R0| 00000910 0d 0a 09 4d 4f 56 09 52 35 2c 52 30 0d 0a 09 4d |...MOV.R5,R0...M| 00000920 4f 56 09 52 36 2c 52 30 0d 0a 09 4d 4f 56 09 52 |OV.R6,R0...MOV.R| 00000930 37 2c 52 30 0d 0a 09 4d 4f 56 09 52 38 2c 52 30 |7,R0...MOV.R8,R0| 00000940 0d 0a 09 4d 4f 56 09 52 39 2c 52 30 0d 0a 09 4d |...MOV.R9,R0...M| 00000950 4f 56 09 52 31 30 2c 52 30 0d 0a 09 4d 4f 56 09 |OV.R10,R0...MOV.| 00000960 52 31 31 2c 52 30 0d 0a 09 4c 44 52 09 52 31 32 |R11,R0...LDR.R12| 00000970 2c 73 63 72 65 65 6e 5f 73 74 61 72 74 0d 0a 09 |,screen_start...| 00000980 4c 44 52 09 52 31 34 2c 73 63 72 65 65 6e 5f 73 |LDR.R14,screen_s| 00000990 69 7a 65 0d 0a 09 53 55 42 09 52 31 34 2c 52 31 |ize...SUB.R14,R1| 000009a0 34 2c 23 34 38 0d 0a 50 6f 70 63 6f 72 6e 5f 43 |4,#48..Popcorn_C| 000009b0 6c 65 61 72 53 63 72 65 65 6e 5f 6c 6f 6f 70 0d |learScreen_loop.| 000009c0 0a 09 53 54 4d 49 41 09 52 31 32 21 2c 7b 52 30 |..STMIA.R12!,{R0| 000009d0 2d 52 31 31 7d 20 3b 20 53 74 6f 72 65 20 34 38 |-R11} ; Store 48| 000009e0 20 62 79 74 65 73 20 61 74 20 61 20 74 69 6d 65 | bytes at a time| 000009f0 0d 0a 09 53 55 42 53 09 52 31 34 2c 52 31 34 2c |...SUBS.R14,R14,| 00000a00 23 34 38 0d 0a 09 42 47 45 09 50 6f 70 63 6f 72 |#48...BGE.Popcor| 00000a10 6e 5f 43 6c 65 61 72 53 63 72 65 65 6e 5f 6c 6f |n_ClearScreen_lo| 00000a20 6f 70 0d 0a 09 41 44 44 09 52 31 34 2c 52 31 34 |op...ADD.R14,R14| 00000a30 2c 23 34 38 0d 0a 09 54 53 54 09 52 31 34 2c 23 |,#48...TST.R14,#| 00000a40 33 32 0d 0a 09 53 54 4d 45 51 49 41 09 52 31 32 |32...STMEQIA.R12| 00000a50 21 2c 7b 52 30 2d 52 37 7d 20 20 3b 20 54 68 65 |!,{R0-R7} ; The| 00000a60 6e 20 63 61 72 72 79 20 6f 6e 20 69 6e 20 64 65 |n carry on in de| 00000a70 63 72 65 61 73 69 6e 67 20 70 6f 77 65 72 73 20 |creasing powers | 00000a80 6f 66 20 74 77 6f 0d 0a 09 54 53 54 09 52 31 34 |of two...TST.R14| 00000a90 2c 23 31 36 0d 0a 09 53 54 4d 45 51 49 41 09 52 |,#16...STMEQIA.R| 00000aa0 31 32 21 2c 7b 52 30 2d 52 33 7d 0d 0a 09 54 53 |12!,{R0-R3}...TS| 00000ab0 54 09 52 34 2c 23 38 0d 0a 09 53 54 4d 45 51 49 |T.R4,#8...STMEQI| 00000ac0 41 09 52 31 32 21 2c 7b 52 30 2d 52 31 7d 0d 0a |A.R12!,{R0-R1}..| 00000ad0 09 54 53 54 09 52 34 2c 23 34 0d 0a 09 53 54 52 |.TST.R4,#4...STR| 00000ae0 45 51 09 52 30 2c 5b 52 31 32 5d 2c 23 34 0d 0a |EQ.R0,[R12],#4..| 00000af0 09 54 53 54 09 52 34 2c 23 32 0d 0a 09 53 54 52 |.TST.R4,#2...STR| 00000b00 45 51 42 09 52 30 2c 5b 52 31 32 5d 2c 23 31 0d |EQB.R0,[R12],#1.| 00000b10 0a 09 53 54 52 45 51 42 09 52 30 2c 5b 52 31 32 |..STREQB.R0,[R12| 00000b20 5d 2c 23 31 0d 0a 09 54 53 54 09 52 34 2c 23 31 |],#1...TST.R4,#1| 00000b30 0d 0a 09 53 54 52 45 51 42 09 52 30 2c 5b 52 31 |...STREQB.R0,[R1| 00000b40 32 5d 2c 23 31 0d 0a 09 4c 44 4d 46 44 09 52 31 |2],#1...LDMFD.R1| 00000b50 33 21 2c 7b 52 30 2d 52 31 32 2c 50 43 7d 0d 0a |3!,{R0-R12,PC}..| 00000b60 0d 0a 50 6f 70 63 6f 72 6e 5f 50 6c 6f 74 42 61 |..Popcorn_PlotBa| 00000b70 63 6b 64 72 6f 70 0d 0a 3b 0d 0a 3b 20 45 6e 74 |ckdrop..;..; Ent| 00000b80 65 72 20 77 69 74 68 20 52 30 20 3e 20 62 61 63 |er with R0 > bac| 00000b90 6b 64 72 6f 70 20 64 61 74 61 3b 20 73 69 6d 69 |kdrop data; simi| 00000ba0 6c 61 72 20 74 6f 20 61 62 6f 76 65 20 72 6f 75 |lar to above rou| 00000bb0 74 69 6e 65 0d 0a 3b 0d 0a 09 53 54 4d 46 44 09 |tine..;...STMFD.| 00000bc0 52 31 33 21 2c 7b 52 30 2d 52 31 32 2c 52 31 34 |R13!,{R0-R12,R14| 00000bd0 7d 0d 0a 09 4c 44 52 09 52 31 32 2c 73 63 72 65 |}...LDR.R12,scre| 00000be0 65 6e 5f 73 74 61 72 74 0d 0a 09 4c 44 52 09 52 |en_start...LDR.R| 00000bf0 31 34 2c 73 63 72 65 65 6e 5f 73 69 7a 65 0d 0a |14,screen_size..| 00000c00 09 4d 4f 56 09 52 31 31 2c 52 30 0d 0a 09 53 55 |.MOV.R11,R0...SU| 00000c10 42 53 09 52 31 34 2c 52 31 34 2c 23 34 34 0d 0a |BS.R14,R14,#44..| 00000c20 50 6f 70 63 6f 72 6e 5f 50 6c 6f 74 42 61 63 6b |Popcorn_PlotBack| 00000c30 64 72 6f 70 5f 6c 6f 6f 70 0d 0a 09 4c 44 4d 49 |drop_loop...LDMI| 00000c40 41 09 52 31 31 21 2c 7b 52 30 2d 52 31 30 7d 0d |A.R11!,{R0-R10}.| 00000c50 0a 09 53 54 4d 49 41 09 52 31 32 21 2c 7b 52 30 |..STMIA.R12!,{R0| 00000c60 2d 52 31 30 7d 0d 0a 09 53 55 42 53 09 52 31 34 |-R10}...SUBS.R14| 00000c70 2c 52 31 34 2c 23 34 34 0d 0a 09 42 47 45 09 50 |,R14,#44...BGE.P| 00000c80 6f 70 63 6f 72 6e 5f 50 6c 6f 74 42 61 63 6b 64 |opcorn_PlotBackd| 00000c90 72 6f 70 5f 6c 6f 6f 70 0d 0a 09 41 44 44 09 52 |rop_loop...ADD.R| 00000ca0 31 34 2c 52 31 34 2c 23 34 34 0d 0a 09 54 53 54 |14,R14,#44...TST| 00000cb0 09 52 31 34 2c 23 33 32 0d 0a 09 4c 44 4d 45 51 |.R14,#32...LDMEQ| 00000cc0 49 41 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d 0d |IA.R11!,{R0-R7}.| 00000cd0 0a 09 53 54 4d 45 51 49 41 09 52 31 32 21 2c 7b |..STMEQIA.R12!,{| 00000ce0 52 30 2d 52 37 7d 0d 0a 09 54 53 54 09 52 31 34 |R0-R7}...TST.R14| 00000cf0 2c 23 31 36 0d 0a 09 4c 44 4d 45 51 49 41 09 52 |,#16...LDMEQIA.R| 00000d00 31 31 21 2c 7b 52 30 2d 52 33 7d 0d 0a 09 53 54 |11!,{R0-R3}...ST| 00000d10 4d 45 51 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 |MEQIA.R12!,{R0-R| 00000d20 33 7d 0d 0a 09 54 53 54 09 52 34 2c 23 38 0d 0a |3}...TST.R4,#8..| 00000d30 09 4c 44 4d 45 51 49 41 09 52 31 31 21 2c 7b 52 |.LDMEQIA.R11!,{R| 00000d40 30 2d 52 31 7d 0d 0a 09 53 54 4d 45 51 49 41 09 |0-R1}...STMEQIA.| 00000d50 52 31 32 21 2c 7b 52 30 2d 52 31 7d 0d 0a 09 54 |R12!,{R0-R1}...T| 00000d60 53 54 09 52 34 2c 23 34 0d 0a 09 4c 44 52 45 51 |ST.R4,#4...LDREQ| 00000d70 09 52 30 2c 5b 52 31 31 5d 2c 23 34 0d 0a 09 53 |.R0,[R11],#4...S| 00000d80 54 52 45 51 09 52 30 2c 5b 52 31 32 5d 2c 23 34 |TREQ.R0,[R12],#4| 00000d90 0d 0a 09 54 53 54 09 52 34 2c 23 32 0d 0a 09 4c |...TST.R4,#2...L| 00000da0 44 52 45 51 42 09 52 30 2c 5b 52 31 31 5d 2c 23 |DREQB.R0,[R11],#| 00000db0 31 0d 0a 09 53 54 52 45 51 42 09 52 30 2c 5b 52 |1...STREQB.R0,[R| 00000dc0 31 32 5d 2c 23 31 0d 0a 09 4c 44 52 45 51 42 09 |12],#1...LDREQB.| 00000dd0 52 30 2c 5b 52 31 31 5d 2c 23 31 0d 0a 09 53 54 |R0,[R11],#1...ST| 00000de0 52 45 51 42 09 52 30 2c 5b 52 31 32 5d 2c 23 31 |REQB.R0,[R12],#1| 00000df0 0d 0a 09 54 53 54 09 52 34 2c 23 31 0d 0a 09 4c |...TST.R4,#1...L| 00000e00 44 52 45 51 42 09 52 30 2c 5b 52 31 31 5d 2c 23 |DREQB.R0,[R11],#| 00000e10 31 0d 0a 09 53 54 52 45 51 42 09 52 30 2c 5b 52 |1...STREQB.R0,[R| 00000e20 31 32 5d 2c 23 31 0d 0a 09 4c 44 4d 46 44 09 52 |12],#1...LDMFD.R| 00000e30 31 33 21 2c 7b 52 30 2d 52 31 32 2c 50 43 7d 0d |13!,{R0-R12,PC}.| 00000e40 0a 0d 0a 50 6f 70 63 6f 72 6e 5f 53 65 74 43 6c |...Popcorn_SetCl| 00000e50 69 70 57 69 6e 64 6f 77 0d 0a 09 53 54 4d 46 44 |ipWindow...STMFD| 00000e60 09 52 31 33 21 2c 7b 52 31 34 7d 0d 0a 09 53 54 |.R13!,{R14}...ST| 00000e70 52 09 52 30 2c 73 63 72 65 65 6e 5f 63 6c 69 70 |R.R0,screen_clip| 00000e80 5f 6c 65 66 74 0d 0a 09 53 54 52 09 52 31 2c 73 |_left...STR.R1,s| 00000e90 63 72 65 65 6e 5f 63 6c 69 70 5f 74 6f 70 0d 0a |creen_clip_top..| 00000ea0 09 53 54 52 09 52 32 2c 73 63 72 65 65 6e 5f 63 |.STR.R2,screen_c| 00000eb0 6c 69 70 5f 72 69 67 68 74 0d 0a 09 53 54 52 09 |lip_right...STR.| 00000ec0 52 33 2c 73 63 72 65 65 6e 5f 63 6c 69 70 5f 62 |R3,screen_clip_b| 00000ed0 6f 74 74 6f 6d 0d 0a 09 4c 44 4d 46 44 09 52 31 |ottom...LDMFD.R1| 00000ee0 33 21 2c 7b 50 43 7d 0d 0a 0d 0a 50 6f 70 63 6f |3!,{PC}....Popco| 00000ef0 72 6e 5f 50 6c 6f 74 53 70 72 69 74 65 0d 0a 3b |rn_PlotSprite..;| 00000f00 0d 0a 3b 20 45 6e 74 65 72 20 77 69 74 68 20 52 |..; Enter with R| 00000f10 30 20 3e 20 73 70 72 69 74 65 20 64 61 74 61 2c |0 > sprite data,| 00000f20 20 66 6f 72 6d 61 74 20 61 73 20 64 65 73 63 72 | format as descr| 00000f30 69 62 65 64 20 69 6e 20 6d 61 67 61 7a 69 6e 65 |ibed in magazine| 00000f40 0d 0a 3b 09 20 20 20 20 20 52 31 20 3d 20 78 20 |..;. R1 = x | 00000f50 63 6f 75 6e 74 69 6e 67 20 72 69 67 68 74 20 66 |counting right f| 00000f60 72 6f 6d 20 30 20 28 6c 65 66 74 29 0d 0a 3b 09 |rom 0 (left)..;.| 00000f70 20 20 20 20 20 52 32 20 3d 20 79 20 63 6f 75 6e | R2 = y coun| 00000f80 74 69 6e 67 20 64 6f 77 6e 20 66 72 6f 6d 20 30 |ting down from 0| 00000f90 20 28 74 6f 70 29 0d 0a 3b 0d 0a 09 53 54 4d 46 | (top)..;...STMF| 00000fa0 44 09 52 31 33 21 2c 7b 52 30 2d 52 31 32 2c 52 |D.R13!,{R0-R12,R| 00000fb0 31 34 7d 0d 0a 3b 0d 0a 3b 20 46 69 72 73 74 20 |14}..;..; First | 00000fc0 74 68 69 6e 67 20 77 65 20 6e 65 65 64 20 74 6f |thing we need to| 00000fd0 20 64 6f 20 69 73 20 64 65 63 69 64 65 20 69 66 | do is decide if| 00000fe0 20 77 65 27 72 65 20 74 6f 74 61 6c 6c 79 20 6f | we're totally o| 00000ff0 66 66 0d 0a 3b 0d 0a 09 4c 44 52 09 52 33 2c 5b |ff..;...LDR.R3,[| 00001000 52 30 2c 23 30 5d 09 3b 20 57 69 64 74 68 20 6f |R0,#0].; Width o| 00001010 66 20 73 70 72 69 74 65 0d 0a 09 4c 44 52 09 52 |f sprite...LDR.R| 00001020 34 2c 5b 52 30 2c 23 34 5d 09 3b 20 48 65 69 67 |4,[R0,#4].; Heig| 00001030 68 74 20 6f 66 20 73 70 72 69 74 65 0d 0a 09 41 |ht of sprite...A| 00001040 44 44 09 52 33 2c 52 33 2c 23 31 0d 0a 09 41 44 |DD.R3,R3,#1...AD| 00001050 44 09 52 34 2c 52 34 2c 23 31 0d 0a 09 41 44 44 |D.R4,R4,#1...ADD| 00001060 09 52 33 2c 52 33 2c 52 31 09 3b 20 52 33 20 3d |.R3,R3,R1.; R3 =| 00001070 20 66 75 72 74 68 65 73 74 20 72 69 67 68 74 20 | furthest right | 00001080 70 69 78 65 6c 20 74 6f 20 62 65 20 70 6c 6f 74 |pixel to be plot| 00001090 74 65 64 0d 0a 09 41 44 44 09 52 34 2c 52 34 2c |ted...ADD.R4,R4,| 000010a0 52 32 09 3b 20 52 34 20 3d 20 6c 6f 77 65 73 74 |R2.; R4 = lowest| 000010b0 20 70 69 78 65 6c 20 74 6f 20 62 65 20 70 6c 6f | pixel to be plo| 000010c0 74 74 65 64 0d 0a 09 4c 44 52 09 52 35 2c 73 63 |tted...LDR.R5,sc| 000010d0 72 65 65 6e 5f 63 6c 69 70 5f 62 6f 74 74 6f 6d |reen_clip_bottom| 000010e0 0d 0a 09 4c 44 52 09 52 36 2c 73 63 72 65 65 6e |...LDR.R6,screen| 000010f0 5f 63 6c 69 70 5f 74 6f 70 0d 0a 09 4c 44 52 09 |_clip_top...LDR.| 00001100 52 37 2c 73 63 72 65 65 6e 5f 63 6c 69 70 5f 6c |R7,screen_clip_l| 00001110 65 66 74 0d 0a 09 4c 44 52 09 52 38 2c 73 63 72 |eft...LDR.R8,scr| 00001120 65 65 6e 5f 63 6c 69 70 5f 72 69 67 68 74 0d 0a |een_clip_right..| 00001130 09 43 4d 50 09 52 31 2c 52 38 0d 0a 09 4c 44 4d |.CMP.R1,R8...LDM| 00001140 47 54 46 44 09 52 31 33 21 2c 7b 52 30 2d 52 31 |GTFD.R13!,{R0-R1| 00001150 32 2c 50 43 7d 5e 09 3b 20 4f 66 66 20 72 69 67 |2,PC}^.; Off rig| 00001160 68 74 3f 0d 0a 09 43 4d 50 09 52 32 2c 52 35 0d |ht?...CMP.R2,R5.| 00001170 0a 09 4c 44 4d 47 54 46 44 09 52 31 33 21 2c 7b |..LDMGTFD.R13!,{| 00001180 52 30 2d 52 31 32 2c 50 43 7d 5e 09 3b 20 4f 66 |R0-R12,PC}^.; Of| 00001190 66 20 62 6f 74 74 6f 6d 3f 0d 0a 09 43 4d 50 09 |f bottom?...CMP.| 000011a0 52 33 2c 52 37 0d 0a 09 4c 44 4d 4c 54 46 44 09 |R3,R7...LDMLTFD.| 000011b0 52 31 33 21 2c 7b 52 30 2d 52 31 32 2c 50 43 7d |R13!,{R0-R12,PC}| 000011c0 5e 09 3b 20 4f 66 66 20 6c 65 66 74 3f 0d 0a 09 |^.; Off left?...| 000011d0 43 4d 50 09 52 34 2c 52 36 0d 0a 09 4c 44 4d 4c |CMP.R4,R6...LDML| 000011e0 54 46 44 09 52 31 33 21 2c 7b 52 30 2d 52 31 32 |TFD.R13!,{R0-R12| 000011f0 2c 50 43 7d 5e 09 3b 20 4f 66 66 20 74 6f 70 3f |,PC}^.; Off top?| 00001200 0d 0a 0d 0a 09 53 54 52 09 52 34 2c 6c 61 73 74 |.....STR.R4,last| 00001210 5f 79 09 09 3b 20 53 74 6f 72 65 20 66 6f 72 20 |_y..; Store for | 00001220 6c 61 74 65 72 0d 0a 09 53 54 52 09 52 31 2c 66 |later...STR.R1,f| 00001230 69 72 73 74 5f 78 09 09 3b 20 6c 69 6b 65 77 69 |irst_x..; likewi| 00001240 73 65 0d 0a 3b 0d 0a 3b 20 4e 6f 77 20 77 65 20 |se..;..; Now we | 00001250 6b 6e 6f 77 20 77 65 20 68 61 76 65 20 61 20 73 |know we have a s| 00001260 70 72 69 74 65 20 77 68 69 63 68 20 69 73 20 61 |prite which is a| 00001270 74 20 6c 65 61 73 74 20 70 61 72 74 69 61 6c 6c |t least partiall| 00001280 79 20 6f 6e 20 73 63 72 65 65 6e 2c 0d 0a 3b 20 |y on screen,..; | 00001290 77 65 20 6e 65 65 64 20 74 6f 20 66 69 6e 64 20 |we need to find | 000012a0 74 68 65 20 66 69 72 73 74 20 62 79 74 65 20 74 |the first byte t| 000012b0 6f 20 73 74 61 72 74 20 70 6c 6f 74 74 69 6e 67 |o start plotting| 000012c0 20 61 74 20 6f 6e 20 74 68 65 20 66 69 73 72 74 | at on the fisrt| 000012d0 0d 0a 3b 20 73 63 61 6e 20 6c 69 6e 65 0d 0a 3b |..; scan line..;| 000012e0 0d 0a 3b 20 53 74 61 72 74 20 3d 20 73 63 72 65 |..; Start = scre| 000012f0 65 6e 20 62 61 73 65 20 61 64 64 72 65 73 73 20 |en base address | 00001300 2b 20 78 20 70 6f 73 69 74 69 6f 6e 20 2b 20 28 |+ x position + (| 00001310 79 20 70 6f 73 69 74 69 6f 6e 20 2a 20 6c 69 6e |y position * lin| 00001320 65 20 6c 65 6e 67 74 68 29 0d 0a 3b 0d 0a 09 4c |e length)..;...L| 00001330 44 52 09 52 33 2c 73 63 72 65 65 6e 5f 73 74 61 |DR.R3,screen_sta| 00001340 72 74 0d 0a 09 4c 44 52 09 52 34 2c 73 63 72 65 |rt...LDR.R4,scre| 00001350 65 6e 5f 6c 61 73 74 78 70 69 78 0d 0a 09 41 44 |en_lastxpix...AD| 00001360 44 09 52 34 2c 52 34 2c 23 31 0d 0a 09 4d 4c 41 |D.R4,R4,#1...MLA| 00001370 09 52 31 31 2c 52 32 2c 52 34 2c 52 33 0d 0a 09 |.R11,R2,R4,R3...| 00001380 41 44 44 09 52 31 31 2c 52 31 31 2c 52 31 0d 0a |ADD.R11,R11,R1..| 00001390 3b 20 53 6f 20 6e 6f 77 20 77 65 27 6c 6c 20 6b |; So now we'll k| 000013a0 65 65 70 20 52 31 31 20 61 73 20 6f 75 72 20 27 |eep R11 as our '| 000013b0 70 6c 6f 74 20 68 65 72 65 27 20 72 65 67 69 73 |plot here' regis| 000013c0 74 65 72 0d 0a 0d 0a 3b 20 57 65 20 6e 6f 77 20 |ter....; We now | 000013d0 6e 65 65 64 20 74 6f 20 66 69 6e 64 20 6f 75 74 |need to find out| 000013e0 20 77 68 65 72 65 20 74 6f 20 73 74 61 72 74 20 | where to start | 000013f0 6c 6f 6f 6b 69 6e 67 20 66 6f 72 20 6f 75 72 20 |looking for our | 00001400 73 63 61 6e 2d 6c 69 6e 65 20 64 61 74 61 0d 0a |scan-line data..| 00001410 3b 20 77 68 69 63 68 20 69 73 20 64 65 74 65 72 |; which is deter| 00001420 6d 69 6e 65 64 20 62 79 20 77 68 69 63 68 20 69 |mined by which i| 00001430 6d 61 67 65 20 63 6f 70 79 20 77 65 20 63 68 6f |mage copy we cho| 00001440 6f 73 65 2c 20 77 68 69 63 68 20 69 73 0d 0a 3b |ose, which is..;| 00001450 20 64 65 74 65 72 6d 69 6e 65 64 20 62 79 20 77 | determined by w| 00001460 68 61 74 20 61 6c 69 67 6e 6d 65 6e 74 20 77 65 |hat alignment we| 00001470 20 77 61 6e 74 2e 20 20 53 65 65 3f 20 3a 2d 29 | want. See? :-)| 00001480 0d 0a 3b 0d 0a 09 41 44 44 09 52 31 30 2c 52 30 |..;...ADD.R10,R0| 00001490 2c 23 38 0d 0a 09 41 4e 44 09 52 34 2c 52 31 2c |,#8...AND.R4,R1,| 000014a0 23 33 09 09 3b 20 52 34 20 3d 20 61 6c 69 67 6e |#3..; R4 = align| 000014b0 6d 65 6e 74 0d 0a 09 41 44 44 09 52 31 30 2c 52 |ment...ADD.R10,R| 000014c0 31 30 2c 52 34 2c 4c 53 4c 23 32 0d 0a 09 4c 44 |10,R4,LSL#2...LD| 000014d0 52 09 52 31 30 2c 5b 52 31 30 5d 0d 0a 09 41 44 |R.R10,[R10]...AD| 000014e0 44 09 52 31 30 2c 52 31 30 2c 52 30 09 09 3b 20 |D.R10,R10,R0..; | 000014f0 52 31 30 20 3e 20 73 74 61 72 74 20 6f 66 20 73 |R10 > start of s| 00001500 63 61 6e 2d 6c 69 6e 65 20 64 61 74 61 20 70 74 |can-line data pt| 00001510 72 73 0d 0a 09 53 54 52 09 52 31 30 2c 6e 65 78 |rs...STR.R10,nex| 00001520 74 5f 73 63 61 6e 5f 6c 69 6e 65 5f 70 74 72 0d |t_scan_line_ptr.| 00001530 0a 3b 0d 0a 3b 20 57 65 27 76 65 20 6e 6f 77 20 |.;..; We've now | 00001540 67 6f 74 20 74 68 65 20 27 66 72 6f 6d 27 20 61 |got the 'from' a| 00001550 6e 64 20 27 74 6f 27 20 61 64 64 72 65 73 73 65 |nd 'to' addresse| 00001560 73 2c 20 73 6f 20 73 74 61 72 74 20 70 6c 6f 74 |s, so start plot| 00001570 74 69 6e 67 20 6c 69 6e 65 73 20 6e 6f 77 0d 0a |ting lines now..| 00001580 3b 20 51 75 69 63 6b 20 6c 69 73 74 20 6f 66 20 |; Quick list of | 00001590 72 65 67 69 73 74 65 72 73 20 74 6f 20 6b 65 65 |registers to kee| 000015a0 70 20 68 6f 6c 64 20 6f 66 20 3a 20 52 31 30 20 |p hold of : R10 | 000015b0 3e 20 6e 65 78 74 20 73 63 61 6e 2d 6c 69 6e 65 |> next scan-line| 000015c0 20 64 61 74 61 20 70 74 72 0d 0a 3b 09 09 09 09 | data ptr..;....| 000015d0 09 20 20 20 20 52 31 31 20 3e 20 6e 65 78 74 20 |. R11 > next | 000015e0 73 63 72 65 65 6e 20 61 64 64 72 65 73 73 0d 0a |screen address..| 000015f0 3b 09 09 09 09 09 20 20 20 20 52 31 32 20 3e 20 |;..... R12 > | 00001600 6e 65 78 74 20 73 63 61 6e 2d 6c 69 6e 65 20 64 |next scan-line d| 00001610 61 74 61 0d 0a 3b 0d 0a 09 42 09 66 69 72 73 74 |ata..;...B.first| 00001620 5f 73 63 61 6e 5f 6c 69 6e 65 09 09 3b 20 53 6b |_scan_line..; Sk| 00001630 69 70 20 62 69 74 20 74 6f 20 69 6e 63 72 65 61 |ip bit to increa| 00001640 73 65 20 63 6f 75 6e 74 65 72 73 0d 0a 6e 65 78 |se counters..nex| 00001650 74 5f 73 63 61 6e 5f 6c 69 6e 65 0d 0a 09 41 44 |t_scan_line...AD| 00001660 44 09 52 32 2c 52 32 2c 23 31 0d 0a 09 4c 44 52 |D.R2,R2,#1...LDR| 00001670 09 52 33 2c 6c 61 73 74 5f 79 0d 0a 09 43 4d 50 |.R3,last_y...CMP| 00001680 09 52 32 2c 52 33 09 09 09 3b 20 43 68 65 63 6b |.R2,R3...; Check| 00001690 20 77 65 27 76 65 20 6e 6f 74 20 66 69 6e 69 73 | we've not finis| 000016a0 68 65 64 0d 0a 09 42 45 51 09 66 69 6e 69 73 68 |hed...BEQ.finish| 000016b0 65 64 5f 70 6c 6f 74 0d 0a 09 4c 44 52 09 52 31 |ed_plot...LDR.R1| 000016c0 31 2c 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 6e 65 |1,next_scan_line| 000016d0 5f 61 64 64 72 65 73 73 20 3b 20 4d 6f 76 65 20 |_address ; Move | 000016e0 52 31 31 20 74 6f 20 6e 65 78 74 20 73 63 61 6e |R11 to next scan| 000016f0 20 6c 69 6e 65 0d 0a 66 69 72 73 74 5f 73 63 61 | line..first_sca| 00001700 6e 5f 6c 69 6e 65 09 09 09 09 3b 20 52 65 67 69 |n_line....; Regi| 00001710 73 74 65 72 73 20 61 6c 72 65 61 64 79 20 73 65 |sters already se| 00001720 74 20 75 70 21 0d 0a 3b 0d 0a 3b 20 46 69 72 73 |t up!..;..; Firs| 00001730 74 20 74 68 69 6e 67 20 74 6f 20 64 6f 20 69 73 |t thing to do is| 00001740 20 77 6f 72 6b 20 6f 75 74 20 77 68 65 72 65 20 | work out where | 00001750 74 68 65 20 73 74 61 72 74 20 6f 66 20 74 68 65 |the start of the| 00001760 20 6e 65 78 74 20 73 63 61 6e 20 6c 69 6e 65 0d | next scan line.| 00001770 0a 3b 20 73 68 6f 75 6c 64 20 62 65 20 74 6f 20 |.; should be to | 00001780 61 76 6f 69 64 20 6d 65 73 73 79 20 63 61 6c 63 |avoid messy calc| 00001790 75 6c 61 74 69 6f 6e 73 20 6c 61 74 65 72 0d 0a |ulations later..| 000017a0 3b 0d 0a 09 4c 44 52 09 52 33 2c 73 63 72 65 65 |;...LDR.R3,scree| 000017b0 6e 5f 6c 61 73 74 78 70 69 78 0d 0a 09 41 44 44 |n_lastxpix...ADD| 000017c0 09 52 33 2c 52 33 2c 23 31 0d 0a 09 41 44 44 09 |.R3,R3,#1...ADD.| 000017d0 52 33 2c 52 33 2c 52 31 31 0d 0a 09 53 54 52 09 |R3,R3,R11...STR.| 000017e0 52 33 2c 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 6e |R3,next_scan_lin| 000017f0 65 5f 61 64 64 72 65 73 73 0d 0a 3b 0d 0a 3b 0d |e_address..;..;.| 00001800 0a 3b 20 46 69 72 73 74 20 74 68 69 6e 67 20 74 |.; First thing t| 00001810 6f 20 63 68 65 63 6b 20 66 6f 72 20 69 73 20 79 |o check for is y| 00001820 20 63 6c 69 70 70 69 6e 67 3b 20 69 66 20 77 65 | clipping; if we| 00001830 27 72 65 20 6e 6f 74 20 6f 6e 20 74 6f 70 20 6f |'re not on top o| 00001840 72 20 62 6f 74 74 6f 6d 2c 0d 0a 3b 20 74 68 65 |r bottom,..; the| 00001850 72 65 27 73 20 6e 6f 20 70 6f 69 6e 74 20 69 6e |re's no point in| 00001860 20 67 6f 69 6e 67 20 61 6e 79 20 66 75 72 74 68 | going any furth| 00001870 65 72 0d 0a 3b 0d 0a 09 4c 44 52 09 52 33 2c 73 |er..;...LDR.R3,s| 00001880 63 72 65 65 6e 5f 63 6c 69 70 5f 62 6f 74 74 6f |creen_clip_botto| 00001890 6d 0d 0a 09 43 4d 50 09 52 32 2c 52 33 0d 0a 09 |m...CMP.R2,R3...| 000018a0 42 47 54 09 66 69 6e 69 73 68 65 64 5f 70 6c 6f |BGT.finished_plo| 000018b0 74 09 09 3b 20 46 69 6e 69 73 68 65 64 20 69 66 |t..; Finished if| 000018c0 20 77 65 27 72 65 20 6f 66 66 20 74 68 65 20 62 | we're off the b| 000018d0 6f 74 74 6f 6d 0d 0a 09 4c 44 52 09 52 33 2c 73 |ottom...LDR.R3,s| 000018e0 63 72 65 65 6e 5f 63 6c 69 70 5f 74 6f 70 0d 0a |creen_clip_top..| 000018f0 09 43 4d 50 09 52 32 2c 52 33 0d 0a 09 41 44 44 |.CMP.R2,R3...ADD| 00001900 4c 54 09 52 31 30 2c 52 31 30 2c 23 34 0d 0a 09 |LT.R10,R10,#4...| 00001910 42 4c 54 09 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 |BLT.next_scan_li| 00001920 6e 65 09 09 3b 20 54 72 79 20 6e 65 78 74 20 6c |ne..; Try next l| 00001930 69 6e 65 20 69 66 20 77 65 27 72 65 20 6f 66 66 |ine if we're off| 00001940 20 74 68 65 20 74 6f 70 0d 0a 3b 0d 0a 3b 20 52 | the top..;..; R| 00001950 69 67 68 74 2c 20 6e 6f 77 20 77 65 20 6b 6e 6f |ight, now we kno| 00001960 77 20 77 65 20 68 61 76 65 20 61 20 73 63 61 6e |w we have a scan| 00001970 20 6c 69 6e 65 20 77 68 69 63 68 20 69 73 20 69 | line which is i| 00001980 6e 20 74 68 65 20 70 6c 6f 74 20 77 69 6e 64 6f |n the plot windo| 00001990 77 0d 0a 3b 20 69 6e 20 74 68 65 20 79 20 64 69 |w..; in the y di| 000019a0 72 65 63 74 69 6f 6e 20 61 6e 79 77 61 79 2c 20 |rection anyway, | 000019b0 73 6f 20 77 65 20 6d 75 73 74 20 68 61 76 65 20 |so we must have | 000019c0 73 6f 6d 65 74 68 69 6e 67 20 74 6f 20 70 6c 6f |something to plo| 000019d0 74 2c 20 73 6f 20 67 65 74 0d 0a 3b 20 74 68 65 |t, so get..; the| 000019e0 20 73 74 61 72 74 20 6f 66 20 74 68 65 20 73 63 | start of the sc| 000019f0 61 6e 20 6c 69 6e 65 20 64 61 74 61 0d 0a 3b 0d |an line data..;.| 00001a00 0a 0d 0a 3b 0d 0a 3b 20 46 65 74 63 68 20 74 68 |...;..; Fetch th| 00001a10 65 20 61 64 64 72 65 73 73 20 6f 66 20 74 68 65 |e address of the| 00001a20 20 66 69 72 73 74 20 70 61 72 74 20 6f 66 20 74 | first part of t| 00001a30 68 65 20 73 63 61 6e 20 6c 69 6e 65 20 69 6e 74 |he scan line int| 00001a40 6f 20 52 31 32 0d 0a 3b 20 61 6e 64 20 6d 6f 76 |o R12..; and mov| 00001a50 65 20 52 31 30 20 61 6c 6f 6e 67 0d 0a 3b 0d 0a |e R10 along..;..| 00001a60 09 4c 44 52 09 52 31 2c 66 69 72 73 74 5f 78 09 |.LDR.R1,first_x.| 00001a70 09 3b 20 52 65 73 65 74 20 52 31 20 74 6f 20 73 |.; Reset R1 to s| 00001a80 74 61 72 74 20 6f 66 20 6c 69 6e 65 0d 0a 09 4c |tart of line...L| 00001a90 44 52 09 52 31 32 2c 5b 52 31 30 5d 2c 23 34 0d |DR.R12,[R10],#4.| 00001aa0 0a 09 41 44 44 09 52 31 32 2c 52 31 32 2c 52 30 |..ADD.R12,R12,R0| 00001ab0 09 09 3b 20 47 65 74 20 73 63 61 6e 20 6c 69 6e |..; Get scan lin| 00001ac0 65 20 70 74 72 20 69 6e 74 6f 20 52 31 32 0d 0a |e ptr into R12..| 00001ad0 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 6e 65 5f 62 |next_scan_line_b| 00001ae0 69 74 0d 0a 09 4c 44 52 09 52 39 2c 5b 52 31 32 |it...LDR.R9,[R12| 00001af0 5d 2c 23 34 09 09 3b 20 47 65 74 20 61 63 74 69 |],#4..; Get acti| 00001b00 6f 6e 20 63 6f 64 65 20 69 6e 74 6f 20 52 39 0d |on code into R9.| 00001b10 0a 09 4d 4f 56 09 52 38 2c 52 39 2c 4c 53 52 23 |..MOV.R8,R9,LSR#| 00001b20 32 34 09 09 3b 20 52 38 20 3d 20 61 63 74 69 6f |24..; R8 = actio| 00001b30 6e 0d 0a 09 42 49 43 09 52 39 2c 52 39 2c 23 26 |n...BIC.R9,R9,#&| 00001b40 46 46 30 30 30 30 30 30 09 3b 20 52 39 20 3d 20 |FF000000.; R9 = | 00001b50 6e 75 6d 62 65 72 20 6f 66 20 62 79 74 65 73 0d |number of bytes.| 00001b60 0a 3b 0d 0a 3b 20 4e 6f 77 20 74 61 6b 65 20 73 |.;..; Now take s| 00001b70 6f 6d 65 20 61 63 74 69 6f 6e 20 6f 6e 20 52 38 |ome action on R8| 00001b80 2c 20 6f 72 20 72 61 74 68 65 72 20 6a 75 73 74 |, or rather just| 00001b90 20 63 68 65 63 6b 20 69 66 20 69 74 20 69 73 20 | check if it is | 00001ba0 7a 65 72 6f 0d 0a 3b 0d 0a 09 43 4d 50 09 52 38 |zero..;...CMP.R8| 00001bb0 2c 23 32 0d 0a 09 42 47 54 09 75 68 5f 6f 68 0d |,#2...BGT.uh_oh.| 00001bc0 0a 09 43 4d 50 09 52 38 2c 23 30 0d 0a 09 42 45 |..CMP.R8,#0...BE| 00001bd0 51 09 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 6e 65 |Q.next_scan_line| 00001be0 0d 0a 3b 20 4f 74 68 65 72 77 69 73 65 20 77 6f |..; Otherwise wo| 00001bf0 72 6b 20 6f 75 74 20 52 35 20 61 6e 64 20 63 61 |rk out R5 and ca| 00001c00 72 72 79 20 6f 6e 0d 0a 09 41 44 44 09 52 35 2c |rry on...ADD.R5,| 00001c10 52 31 2c 52 39 09 09 3b 20 52 35 20 3d 20 78 20 |R1,R9..; R5 = x | 00001c20 70 6f 73 69 74 69 6f 6e 20 61 66 74 65 72 20 70 |position after p| 00001c30 6c 6f 74 0d 0a 3b 0d 0a 3b 20 57 65 20 68 61 76 |lot..;..; We hav| 00001c40 65 20 74 68 65 20 70 6f 73 69 74 69 6f 6e 73 20 |e the positions | 00001c50 6f 66 20 74 68 65 20 66 69 72 73 74 20 61 6e 64 |of the first and| 00001c60 20 6c 61 73 74 20 62 79 74 65 73 20 6f 66 20 74 | last bytes of t| 00001c70 68 65 20 27 62 69 74 27 2c 20 6e 6f 77 0d 0a 3b |he 'bit', now..;| 00001c80 20 77 6f 72 6b 20 6f 75 74 20 77 68 65 74 68 65 | work out whethe| 00001c90 72 20 74 68 65 20 27 62 69 74 27 20 69 73 20 66 |r the 'bit' is f| 00001ca0 75 6c 6c 79 20 6f 6e 2d 73 63 72 65 65 6e 2c 20 |ully on-screen, | 00001cb0 6f 72 20 77 68 65 74 68 65 72 20 77 65 20 6e 65 |or whether we ne| 00001cc0 65 64 0d 0a 3b 20 74 6f 20 64 6f 20 73 6f 6d 65 |ed..; to do some| 00001cd0 20 58 20 63 6c 69 70 70 69 6e 67 0d 0a 3b 0d 0a | X clipping..;..| 00001ce0 09 4c 44 52 09 52 33 2c 73 63 72 65 65 6e 5f 63 |.LDR.R3,screen_c| 00001cf0 6c 69 70 5f 6c 65 66 74 0d 0a 09 4c 44 52 09 52 |lip_left...LDR.R| 00001d00 34 2c 73 63 72 65 65 6e 5f 63 6c 69 70 5f 72 69 |4,screen_clip_ri| 00001d10 67 68 74 0d 0a 09 43 4d 50 09 52 31 2c 52 33 0d |ght...CMP.R1,R3.| 00001d20 0a 09 42 4c 54 09 63 6c 69 70 5f 6c 65 66 74 0d |..BLT.clip_left.| 00001d30 0a 09 43 4d 50 09 52 35 2c 52 34 0d 0a 09 42 47 |..CMP.R5,R4...BG| 00001d40 54 09 63 6c 69 70 5f 72 69 67 68 74 0d 0a 09 42 |T.clip_right...B| 00001d50 09 6e 6f 5f 63 6c 69 70 70 69 6e 67 0d 0a 3b 0d |.no_clipping..;.| 00001d60 0a 3b 20 52 65 6c 65 76 61 6e 74 20 72 65 67 69 |.; Relevant regi| 00001d70 73 74 65 72 73 20 66 6f 72 20 58 20 63 6c 69 70 |sters for X clip| 00001d80 70 69 6e 67 20 2d 2d 20 70 61 79 20 61 74 74 65 |ping -- pay atte| 00001d90 6e 74 69 6f 6e 20 74 6f 20 74 68 69 73 0d 0a 3b |ntion to this..;| 00001da0 0d 0a 3b 20 52 31 20 20 3d 20 78 20 63 6f 2d 6f |..; R1 = x co-o| 00001db0 72 64 69 6e 61 74 65 20 74 6f 20 73 74 61 72 74 |rdinate to start| 00001dc0 20 70 6c 6f 74 74 69 6e 67 20 28 63 6f 75 6c 64 | plotting (could| 00001dd0 20 62 65 20 6f 66 66 20 73 63 72 65 65 6e 3f 29 | be off screen?)| 00001de0 0d 0a 3b 20 52 32 20 20 3d 20 79 20 63 6f 2d 6f |..; R2 = y co-o| 00001df0 72 64 69 6e 61 74 65 20 74 6f 20 73 74 61 72 74 |rdinate to start| 00001e00 20 70 6c 6f 74 74 69 6e 67 0d 0a 3b 20 52 33 20 | plotting..; R3 | 00001e10 20 3d 20 66 69 72 73 74 20 78 20 70 69 78 65 6c | = first x pixel| 00001e20 20 69 6e 20 77 69 6e 64 6f 77 0d 0a 3b 20 52 34 | in window..; R4| 00001e30 20 20 3d 20 6c 61 73 74 20 78 20 70 69 78 65 6c | = last x pixel| 00001e40 20 69 6e 20 77 69 6e 64 6f 77 0d 0a 3b 20 52 35 | in window..; R5| 00001e50 20 20 3d 20 78 20 63 6f 2d 6f 72 64 69 6e 61 74 | = x co-ordinat| 00001e60 65 20 61 66 74 65 72 20 70 6c 6f 74 20 28 6f 66 |e after plot (of| 00001e70 66 20 73 63 72 65 65 6e 3f 29 0d 0a 3b 20 52 38 |f screen?)..; R8| 00001e80 20 20 3d 20 27 74 79 70 65 27 20 70 61 72 74 20 | = 'type' part | 00001e90 6f 66 20 74 79 70 65 20 77 6f 72 64 20 28 69 2e |of type word (i.| 00001ea0 65 2e 20 74 74 29 0d 0a 3b 20 52 39 20 20 3d 20 |e. tt)..; R9 = | 00001eb0 6e 75 6d 62 65 72 20 6f 66 20 62 79 74 65 73 20 |number of bytes | 00001ec0 28 69 2e 65 2e 20 64 64 64 64 29 0d 0a 3b 20 52 |(i.e. dddd)..; R| 00001ed0 31 31 20 3d 20 73 63 72 65 65 6e 20 61 64 64 72 |11 = screen addr| 00001ee0 65 73 73 20 74 6f 20 73 74 61 72 74 0d 0a 3b 20 |ess to start..; | 00001ef0 52 31 32 20 3d 20 73 74 61 72 74 20 61 64 64 72 |R12 = start addr| 00001f00 65 73 73 20 6f 66 20 73 70 72 69 74 65 20 64 61 |ess of sprite da| 00001f10 74 61 0d 0a 3b 0d 0a 63 6c 69 70 5f 6c 65 66 74 |ta..;..clip_left| 00001f20 0d 0a 09 43 4d 50 09 52 38 2c 23 32 0d 0a 09 42 |...CMP.R8,#2...B| 00001f30 4e 45 09 63 6c 69 70 5f 6c 65 66 74 5f 62 69 74 |NE.clip_left_bit| 00001f40 5f 6f 6e 0d 0a 09 41 44 44 09 52 31 31 2c 52 31 |_on...ADD.R11,R1| 00001f50 31 2c 52 39 0d 0a 09 4d 4f 56 09 52 31 2c 52 35 |1,R9...MOV.R1,R5| 00001f60 0d 0a 09 42 09 6e 65 78 74 5f 73 63 61 6e 5f 6c |...B.next_scan_l| 00001f70 69 6e 65 5f 62 69 74 09 3b 20 44 65 61 6c 20 77 |ine_bit.; Deal w| 00001f80 69 74 68 20 6d 61 73 6b 73 20 62 79 20 6a 75 73 |ith masks by jus| 00001f90 74 20 73 68 69 66 74 69 6e 67 0d 0a 09 09 09 09 |t shifting......| 00001fa0 09 3b 20 74 68 65 20 72 65 6c 65 76 61 6e 74 20 |.; the relevant | 00001fb0 70 6f 69 6e 74 65 72 73 20 6f 6e 0d 0a 63 6c 69 |pointers on..cli| 00001fc0 70 5f 6c 65 66 74 5f 62 69 74 5f 6f 6e 0d 0a 09 |p_left_bit_on...| 00001fd0 43 4d 50 09 52 35 2c 52 33 0d 0a 09 42 47 45 09 |CMP.R5,R3...BGE.| 00001fe0 63 6c 69 70 5f 6c 65 66 74 5f 6e 6f 74 5f 63 6f |clip_left_not_co| 00001ff0 6d 70 6c 65 74 65 6c 79 5f 6f 66 66 0d 0a 09 41 |mpletely_off...A| 00002000 4e 44 09 52 37 2c 52 31 31 2c 23 33 0d 0a 09 41 |ND.R7,R11,#3...A| 00002010 44 44 09 52 31 32 2c 52 31 32 2c 52 37 09 09 3b |DD.R12,R12,R7..;| 00002020 20 50 75 73 68 20 52 31 32 20 61 6c 6f 6e 67 20 | Push R12 along | 00002030 61 63 63 6f 72 64 69 6e 67 20 74 6f 20 61 6c 69 |according to ali| 00002040 67 6e 0d 0a 09 41 44 44 09 52 31 32 2c 52 31 32 |gn...ADD.R12,R12| 00002050 2c 52 39 0d 0a 09 41 44 44 09 52 31 31 2c 52 31 |,R9...ADD.R11,R1| 00002060 31 2c 52 39 0d 0a 09 4d 4f 56 09 52 31 2c 52 35 |1,R9...MOV.R1,R5| 00002070 0d 0a 09 42 09 61 6c 69 67 6e 5f 72 31 32 5f 6e |...B.align_r12_n| 00002080 6f 5f 72 65 73 74 6f 72 65 0d 0a 63 6c 69 70 5f |o_restore..clip_| 00002090 6c 65 66 74 5f 6e 6f 74 5f 63 6f 6d 70 6c 65 74 |left_not_complet| 000020a0 65 6c 79 5f 6f 66 66 0d 0a 09 41 4e 44 09 52 37 |ely_off...AND.R7| 000020b0 2c 52 31 31 2c 23 33 0d 0a 09 41 44 44 09 52 31 |,R11,#3...ADD.R1| 000020c0 32 2c 52 31 32 2c 52 37 09 09 3b 20 50 75 73 68 |2,R12,R7..; Push| 000020d0 20 52 31 32 20 61 6c 6f 6e 67 20 61 63 63 6f 72 | R12 along accor| 000020e0 64 69 6e 67 20 74 6f 20 61 6c 69 67 6e 0d 0a 09 |ding to align...| 000020f0 53 55 42 09 52 36 2c 52 33 2c 52 31 09 09 3b 20 |SUB.R6,R3,R1..; | 00002100 52 36 20 3d 20 6e 6f 2e 20 6f 66 20 70 69 78 65 |R6 = no. of pixe| 00002110 6c 73 20 6f 66 66 20 6c 65 66 74 0d 0a 09 41 44 |ls off left...AD| 00002120 44 09 52 31 31 2c 52 31 31 2c 52 36 0d 0a 09 41 |D.R11,R11,R6...A| 00002130 44 44 09 52 31 32 2c 52 31 32 2c 52 36 0d 0a 09 |DD.R12,R12,R6...| 00002140 4d 4f 56 09 52 31 2c 52 35 0d 0a 09 53 55 42 09 |MOV.R1,R5...SUB.| 00002150 52 39 2c 52 39 2c 52 36 09 09 3b 20 41 64 6a 75 |R9,R9,R6..; Adju| 00002160 73 74 20 73 74 61 72 74 20 2f 20 6e 6f 2e 20 6f |st start / no. o| 00002170 66 20 70 69 78 65 6c 73 0d 0a 09 43 4d 50 09 52 |f pixels...CMP.R| 00002180 35 2c 52 34 09 09 09 3b 20 43 68 65 63 6b 20 66 |5,R4...; Check f| 00002190 6f 72 20 63 6c 69 70 20 72 69 67 68 74 20 61 73 |or clip right as| 000021a0 20 77 65 6c 6c 0d 0a 09 42 4c 45 09 73 74 61 72 | well...BLE.star| 000021b0 74 5f 70 6c 6f 74 5f 62 69 74 0d 0a 09 41 44 44 |t_plot_bit...ADD| 000021c0 09 52 34 2c 52 34 2c 23 31 09 09 3b 0d 0a 09 53 |.R4,R4,#1..;...S| 000021d0 55 42 09 52 36 2c 52 35 2c 52 34 09 09 3b 20 43 |UB.R6,R5,R4..; C| 000021e0 6f 64 65 20 63 6f 70 69 65 64 20 66 72 6f 6d 20 |ode copied from | 000021f0 62 65 6c 6f 77 0d 0a 09 53 54 52 09 52 36 2c 63 |below...STR.R6,c| 00002200 6f 6d 70 65 6e 73 61 74 65 5f 72 69 67 68 74 09 |ompensate_right.| 00002210 3b 0d 0a 09 53 55 42 09 52 39 2c 52 39 2c 52 36 |;...SUB.R9,R9,R6| 00002220 09 09 3b 0d 0a 09 42 09 73 74 61 72 74 5f 70 6c |..;...B.start_pl| 00002230 6f 74 5f 62 69 74 09 09 3b 0d 0a 0d 0a 63 6c 69 |ot_bit..;....cli| 00002240 70 5f 72 69 67 68 74 0d 0a 09 43 4d 50 09 52 38 |p_right...CMP.R8| 00002250 2c 23 32 0d 0a 09 42 45 51 09 6e 65 78 74 5f 73 |,#2...BEQ.next_s| 00002260 63 61 6e 5f 6c 69 6e 65 09 09 3b 20 4d 61 73 6b |can_line..; Mask| 00002270 20 6f 66 66 20 72 69 67 68 74 20 2d 3e 20 6e 65 | off right -> ne| 00002280 78 74 20 6c 69 6e 65 0d 0a 09 41 44 44 09 52 34 |xt line...ADD.R4| 00002290 2c 52 34 2c 23 31 09 09 3b 20 41 72 73 65 0d 0a |,R4,#1..; Arse..| 000022a0 09 53 55 42 09 52 36 2c 52 35 2c 52 34 09 09 3b |.SUB.R6,R5,R4..;| 000022b0 20 52 36 20 3d 20 6e 6f 2e 20 6f 66 20 70 69 78 | R6 = no. of pix| 000022c0 65 6c 73 20 6f 66 66 20 72 69 67 68 74 0d 0a 09 |els off right...| 000022d0 53 54 52 09 52 36 2c 63 6f 6d 70 65 6e 73 61 74 |STR.R6,compensat| 000022e0 65 5f 72 69 67 68 74 09 3b 20 43 6f 6d 70 65 6e |e_right.; Compen| 000022f0 73 61 74 65 20 61 66 74 65 72 20 70 6c 6f 74 0d |sate after plot.| 00002300 0a 09 53 55 42 09 52 39 2c 52 39 2c 52 36 09 09 |..SUB.R9,R9,R6..| 00002310 3b 20 43 6c 69 70 20 70 69 78 65 6c 73 20 6f 66 |; Clip pixels of| 00002320 66 20 72 69 67 68 74 0d 0a 09 4d 4f 56 09 52 31 |f right...MOV.R1| 00002330 2c 52 35 0d 0a 09 41 4e 44 09 52 33 2c 52 31 31 |,R5...AND.R3,R11| 00002340 2c 23 33 0d 0a 09 41 44 44 09 52 31 32 2c 52 31 |,#3...ADD.R12,R1| 00002350 32 2c 52 33 0d 0a 09 42 09 73 74 61 72 74 5f 70 |2,R3...B.start_p| 00002360 6c 6f 74 5f 62 69 74 0d 0a 0d 0a 6e 6f 5f 63 6c |lot_bit....no_cl| 00002370 69 70 70 69 6e 67 0d 0a 09 41 44 44 09 52 31 2c |ipping...ADD.R1,| 00002380 52 31 2c 52 39 09 09 3b 20 41 64 6a 75 73 74 20 |R1,R9..; Adjust | 00002390 58 0d 0a 09 43 4d 50 09 52 38 2c 23 32 0d 0a 09 |X...CMP.R8,#2...| 000023a0 41 44 44 45 51 09 52 31 31 2c 52 31 31 2c 52 39 |ADDEQ.R11,R11,R9| 000023b0 0d 0a 09 42 45 51 09 6e 65 78 74 5f 73 63 61 6e |...BEQ.next_scan| 000023c0 5f 6c 69 6e 65 5f 62 69 74 09 3b 20 53 6b 69 70 |_line_bit.; Skip| 000023d0 20 73 63 72 65 65 6e 20 6d 65 6d 6f 72 79 20 69 | screen memory i| 000023e0 66 20 69 74 27 73 20 61 20 6d 61 73 6b 0d 0a 09 |f it's a mask...| 000023f0 41 4e 44 09 52 33 2c 52 31 31 2c 23 33 09 09 3b |AND.R3,R11,#3..;| 00002400 20 47 65 74 20 61 6c 69 67 6e 6d 65 6e 74 20 6f | Get alignment o| 00002410 66 20 73 63 72 65 65 6e 20 61 64 64 72 65 73 73 |f screen address| 00002420 0d 0a 09 41 44 44 09 52 31 32 2c 52 31 32 2c 52 |...ADD.R12,R12,R| 00002430 33 09 09 3b 20 41 64 6a 75 73 74 20 73 74 61 72 |3..; Adjust star| 00002440 74 20 6f 66 20 64 61 74 61 0d 0a 3b 0d 0a 3b 20 |t of data..;..; | 00002450 52 69 67 68 74 2c 20 68 65 72 65 20 69 73 20 77 |Right, here is w| 00002460 68 65 72 65 20 77 65 20 63 61 6e 20 73 74 61 72 |here we can star| 00002470 74 20 70 6c 6f 74 74 69 6e 67 21 0d 0a 3b 20 20 |t plotting!..; | 00002480 20 52 31 32 20 3e 20 73 70 72 69 74 65 20 64 61 | R12 > sprite da| 00002490 74 61 20 28 61 6c 69 67 6e 65 64 2c 20 73 6f 20 |ta (aligned, so | 000024a0 77 61 74 63 68 20 66 6f 72 20 7a 65 72 6f 65 73 |watch for zeroes| 000024b0 20 61 74 20 73 74 61 72 74 29 0d 0a 3b 20 20 20 | at start)..; | 000024c0 52 31 31 20 3e 20 73 63 72 65 65 6e 20 6d 65 6d |R11 > screen mem| 000024d0 6f 72 79 20 74 6f 20 73 74 61 72 74 20 28 61 64 |ory to start (ad| 000024e0 6a 75 73 74 65 64 20 66 6f 72 20 63 6c 69 70 70 |justed for clipp| 000024f0 69 6e 67 29 0d 0a 3b 20 20 20 52 39 20 20 3d 20 |ing)..; R9 = | 00002500 6e 75 6d 62 65 72 20 6f 66 20 62 79 74 65 73 20 |number of bytes | 00002510 74 6f 20 70 6c 6f 74 0d 0a 3b 0d 0a 73 74 61 72 |to plot..;..star| 00002520 74 5f 70 6c 6f 74 5f 62 69 74 0d 0a 09 53 54 4d |t_plot_bit...STM| 00002530 46 44 09 52 31 33 21 2c 7b 52 30 2d 52 37 7d 09 |FD.R13!,{R0-R7}.| 00002540 09 3b 20 4b 65 65 70 20 73 63 72 61 74 63 68 20 |.; Keep scratch | 00002550 72 65 67 69 73 74 65 72 73 0d 0a 09 09 09 09 09 |registers.......| 00002560 3b 20 27 63 6f 73 20 77 65 27 72 65 20 67 6f 69 |; 'cos we're goi| 00002570 6e 67 20 74 6f 20 6f 76 65 72 77 72 69 74 65 20 |ng to overwrite | 00002580 74 68 65 6d 0d 0a 09 09 09 09 09 3b 20 77 69 74 |them.......; wit| 00002590 68 20 6d 75 6c 74 69 70 6c 65 20 6c 6f 61 64 73 |h multiple loads| 000025a0 2f 73 74 6f 72 65 73 0d 0a 3b 0d 0a 3b 20 50 6c |/stores..;..; Pl| 000025b0 6f 74 20 30 2d 33 20 62 79 74 65 73 20 73 6f 20 |ot 0-3 bytes so | 000025c0 77 65 20 73 74 61 72 74 20 6f 6e 20 61 20 77 6f |we start on a wo| 000025d0 72 64 20 62 6f 75 6e 64 61 72 79 0d 0a 3b 0d 0a |rd boundary..;..| 000025e0 09 43 4d 50 09 52 39 2c 23 30 0d 0a 09 42 4c 45 |.CMP.R9,#0...BLE| 000025f0 09 61 6c 69 67 6e 5f 72 31 32 0d 0a 09 54 53 54 |.align_r12...TST| 00002600 09 52 31 31 2c 23 31 0d 0a 09 42 45 51 09 6e 6f |.R11,#1...BEQ.no| 00002610 5f 61 6c 69 67 6e 5f 30 0d 0a 09 4c 44 52 42 09 |_align_0...LDRB.| 00002620 52 30 2c 5b 52 31 32 5d 2c 23 31 0d 0a 09 53 54 |R0,[R12],#1...ST| 00002630 52 42 09 52 30 2c 5b 52 31 31 5d 2c 23 31 0d 0a |RB.R0,[R11],#1..| 00002640 09 53 55 42 53 09 52 39 2c 52 39 2c 23 31 0d 0a |.SUBS.R9,R9,#1..| 00002650 09 42 45 51 09 61 6c 69 67 6e 5f 72 31 32 0d 0a |.BEQ.align_r12..| 00002660 6e 6f 5f 61 6c 69 67 6e 5f 30 0d 0a 09 54 53 54 |no_align_0...TST| 00002670 09 52 31 31 2c 23 32 0d 0a 09 42 45 51 09 6e 6f |.R11,#2...BEQ.no| 00002680 5f 61 6c 69 67 6e 5f 31 0d 0a 09 4c 44 52 42 09 |_align_1...LDRB.| 00002690 52 30 2c 5b 52 31 32 5d 2c 23 31 0d 0a 09 53 54 |R0,[R12],#1...ST| 000026a0 52 42 09 52 30 2c 5b 52 31 31 5d 2c 23 31 0d 0a |RB.R0,[R11],#1..| 000026b0 09 53 55 42 53 09 52 39 2c 52 39 2c 23 31 0d 0a |.SUBS.R9,R9,#1..| 000026c0 09 42 45 51 09 61 6c 69 67 6e 5f 72 31 32 0d 0a |.BEQ.align_r12..| 000026d0 09 4c 44 52 42 09 52 30 2c 5b 52 31 32 5d 2c 23 |.LDRB.R0,[R12],#| 000026e0 31 0d 0a 09 53 54 52 42 09 52 30 2c 5b 52 31 31 |1...STRB.R0,[R11| 000026f0 5d 2c 23 31 0d 0a 09 53 55 42 53 09 52 39 2c 52 |],#1...SUBS.R9,R| 00002700 39 2c 23 31 0d 0a 09 42 45 51 09 61 6c 69 67 6e |9,#1...BEQ.align| 00002710 5f 72 31 32 0d 0a 6e 6f 5f 61 6c 69 67 6e 5f 31 |_r12..no_align_1| 00002720 0d 0a 0d 0a 3b 0d 0a 3b 20 4e 6f 77 20 77 65 27 |....;..; Now we'| 00002730 72 65 20 6f 6e 20 61 20 77 6f 72 64 20 62 6f 75 |re on a word bou| 00002740 6e 64 61 72 79 2c 20 77 65 20 63 61 6e 20 73 74 |ndary, we can st| 00002750 61 72 74 20 70 6c 6f 74 74 69 6e 67 20 62 69 67 |art plotting big| 00002760 20 63 68 75 6e 6b 73 20 77 69 74 68 0d 0a 3b 20 | chunks with..; | 00002770 4c 44 52 20 61 6e 64 20 4c 44 4d 20 69 6e 73 74 |LDR and LDM inst| 00002780 72 75 63 74 69 6f 6e 73 0d 0a 3b 0d 0a 09 54 53 |ructions..;...TS| 00002790 54 09 52 39 2c 23 32 5f 31 30 30 0d 0a 09 42 45 |T.R9,#2_100...BE| 000027a0 51 09 6e 6f 5f 62 69 74 5f 32 0d 0a 09 4c 44 52 |Q.no_bit_2...LDR| 000027b0 09 52 30 2c 5b 52 31 32 5d 2c 23 34 0d 0a 09 53 |.R0,[R12],#4...S| 000027c0 54 52 09 52 30 2c 5b 52 31 31 5d 2c 23 34 0d 0a |TR.R0,[R11],#4..| 000027d0 09 42 49 43 53 09 52 30 2c 52 39 2c 23 32 5f 31 |.BICS.R0,R9,#2_1| 000027e0 31 31 0d 0a 09 42 45 51 09 6e 6f 5f 62 69 74 5f |11...BEQ.no_bit_| 000027f0 38 0d 0a 6e 6f 5f 62 69 74 5f 32 0d 0a 09 54 53 |8..no_bit_2...TS| 00002800 54 09 52 39 2c 23 32 5f 31 30 30 30 0d 0a 09 42 |T.R9,#2_1000...B| 00002810 45 51 09 6e 6f 5f 62 69 74 5f 33 0d 0a 09 4c 44 |EQ.no_bit_3...LD| 00002820 4d 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 31 7d |MIA.R12!,{R0-R1}| 00002830 0d 0a 09 53 54 4d 49 41 09 52 31 31 21 2c 7b 52 |...STMIA.R11!,{R| 00002840 30 2d 52 31 7d 0d 0a 6e 6f 5f 62 69 74 5f 33 0d |0-R1}..no_bit_3.| 00002850 0a 09 54 53 54 09 52 39 2c 23 32 5f 31 30 30 30 |..TST.R9,#2_1000| 00002860 30 0d 0a 09 42 45 51 09 6e 6f 5f 62 69 74 5f 34 |0...BEQ.no_bit_4| 00002870 0d 0a 09 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 |...LDMIA.R12!,{R| 00002880 30 2d 52 33 7d 0d 0a 09 53 54 4d 49 41 09 52 31 |0-R3}...STMIA.R1| 00002890 31 21 2c 7b 52 30 2d 52 33 7d 0d 0a 6e 6f 5f 62 |1!,{R0-R3}..no_b| 000028a0 69 74 5f 34 0d 0a 09 54 53 54 09 52 39 2c 23 32 |it_4...TST.R9,#2| 000028b0 5f 31 30 30 30 30 30 0d 0a 09 42 45 51 09 6e 6f |_100000...BEQ.no| 000028c0 5f 62 69 74 5f 35 0d 0a 09 4c 44 4d 49 41 09 52 |_bit_5...LDMIA.R| 000028d0 31 32 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 |12!,{R0-R7}...ST| 000028e0 4d 49 41 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d |MIA.R11!,{R0-R7}| 000028f0 0d 0a 6e 6f 5f 62 69 74 5f 35 0d 0a 09 54 53 54 |..no_bit_5...TST| 00002900 09 52 39 2c 23 32 5f 31 30 30 30 30 30 30 0d 0a |.R9,#2_1000000..| 00002910 09 42 45 51 09 6e 6f 5f 62 69 74 5f 36 0d 0a 09 |.BEQ.no_bit_6...| 00002920 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 |LDMIA.R12!,{R0-R| 00002930 37 7d 0d 0a 09 53 54 4d 49 41 09 52 31 31 21 2c |7}...STMIA.R11!,| 00002940 7b 52 30 2d 52 37 7d 0d 0a 09 4c 44 4d 49 41 09 |{R0-R7}...LDMIA.| 00002950 52 31 32 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 |R12!,{R0-R7}...S| 00002960 54 4d 49 41 09 52 31 31 21 2c 7b 52 30 2d 52 37 |TMIA.R11!,{R0-R7| 00002970 7d 0d 0a 6e 6f 5f 62 69 74 5f 36 0d 0a 09 54 53 |}..no_bit_6...TS| 00002980 54 09 52 39 2c 23 32 5f 31 30 30 30 30 30 30 30 |T.R9,#2_10000000| 00002990 0d 0a 09 42 45 51 09 6e 6f 5f 62 69 74 5f 37 0d |...BEQ.no_bit_7.| 000029a0 0a 09 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 30 |..LDMIA.R12!,{R0| 000029b0 2d 52 37 7d 0d 0a 09 53 54 4d 49 41 09 52 31 31 |-R7}...STMIA.R11| 000029c0 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 4c 44 4d 49 |!,{R0-R7}...LDMI| 000029d0 41 09 52 31 32 21 2c 7b 52 30 2d 52 37 7d 0d 0a |A.R12!,{R0-R7}..| 000029e0 09 53 54 4d 49 41 09 52 31 31 21 2c 7b 52 30 2d |.STMIA.R11!,{R0-| 000029f0 52 37 7d 0d 0a 09 4c 44 4d 49 41 09 52 31 32 21 |R7}...LDMIA.R12!| 00002a00 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 4d 49 41 |,{R0-R7}...STMIA| 00002a10 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 |.R11!,{R0-R7}...| 00002a20 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 |LDMIA.R12!,{R0-R| 00002a30 37 7d 0d 0a 09 53 54 4d 49 41 09 52 31 31 21 2c |7}...STMIA.R11!,| 00002a40 7b 52 30 2d 52 37 7d 0d 0a 6e 6f 5f 62 69 74 5f |{R0-R7}..no_bit_| 00002a50 37 0d 0a 09 54 53 54 09 52 39 2c 23 32 5f 31 30 |7...TST.R9,#2_10| 00002a60 30 30 30 30 30 30 30 0d 0a 09 42 45 51 09 6e 6f |0000000...BEQ.no| 00002a70 5f 62 69 74 5f 38 0d 0a 09 4c 44 4d 49 41 09 52 |_bit_8...LDMIA.R| 00002a80 31 32 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 |12!,{R0-R7}...ST| 00002a90 4d 49 41 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d |MIA.R11!,{R0-R7}| 00002aa0 0d 0a 09 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 |...LDMIA.R12!,{R| 00002ab0 30 2d 52 37 7d 0d 0a 09 53 54 4d 49 41 09 52 31 |0-R7}...STMIA.R1| 00002ac0 31 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 4c 44 4d |1!,{R0-R7}...LDM| 00002ad0 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 37 7d 0d |IA.R12!,{R0-R7}.| 00002ae0 0a 09 53 54 4d 49 41 09 52 31 31 21 2c 7b 52 30 |..STMIA.R11!,{R0| 00002af0 2d 52 37 7d 0d 0a 09 4c 44 4d 49 41 09 52 31 32 |-R7}...LDMIA.R12| 00002b00 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 4d 49 |!,{R0-R7}...STMI| 00002b10 41 09 52 31 31 21 2c 7b 52 30 2d 52 37 7d 0d 0a |A.R11!,{R0-R7}..| 00002b20 09 4c 44 4d 49 41 09 52 31 32 21 2c 7b 52 30 2d |.LDMIA.R12!,{R0-| 00002b30 52 37 7d 0d 0a 09 53 54 4d 49 41 09 52 31 31 21 |R7}...STMIA.R11!| 00002b40 2c 7b 52 30 2d 52 37 7d 0d 0a 09 4c 44 4d 49 41 |,{R0-R7}...LDMIA| 00002b50 09 52 31 32 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 |.R12!,{R0-R7}...| 00002b60 53 54 4d 49 41 09 52 31 31 21 2c 7b 52 30 2d 52 |STMIA.R11!,{R0-R| 00002b70 37 7d 0d 0a 09 4c 44 4d 49 41 09 52 31 32 21 2c |7}...LDMIA.R12!,| 00002b80 7b 52 30 2d 52 37 7d 0d 0a 09 53 54 4d 49 41 09 |{R0-R7}...STMIA.| 00002b90 52 31 31 21 2c 7b 52 30 2d 52 37 7d 0d 0a 09 4c |R11!,{R0-R7}...L| 00002ba0 44 4d 49 41 09 52 31 32 21 2c 7b 52 30 2d 52 37 |DMIA.R12!,{R0-R7| 00002bb0 7d 0d 0a 09 53 54 4d 49 41 09 52 31 31 21 2c 7b |}...STMIA.R11!,{| 00002bc0 52 30 2d 52 37 7d 0d 0a 6e 6f 5f 62 69 74 5f 38 |R0-R7}..no_bit_8| 00002bd0 0d 0a 3b 0d 0a 3b 20 4e 6f 77 20 77 65 20 73 68 |..;..; Now we sh| 00002be0 6f 75 6c 64 20 68 61 76 65 20 70 6c 6f 74 74 65 |ould have plotte| 00002bf0 64 20 61 6c 6c 20 62 75 74 20 74 68 65 20 6c 61 |d all but the la| 00002c00 73 74 20 30 2d 33 20 62 79 74 65 73 0d 0a 3b 0d |st 0-3 bytes..;.| 00002c10 0a 09 54 53 54 09 52 39 2c 23 32 5f 31 0d 0a 09 |..TST.R9,#2_1...| 00002c20 42 45 51 09 6e 6f 5f 62 69 74 5f 30 0d 0a 09 4c |BEQ.no_bit_0...L| 00002c30 44 52 42 09 52 30 2c 5b 52 31 32 5d 2c 23 31 0d |DRB.R0,[R12],#1.| 00002c40 0a 09 53 54 52 42 09 52 30 2c 5b 52 31 31 5d 2c |..STRB.R0,[R11],| 00002c50 23 31 0d 0a 6e 6f 5f 62 69 74 5f 30 0d 0a 09 54 |#1..no_bit_0...T| 00002c60 53 54 09 52 39 2c 23 32 5f 31 30 0d 0a 09 42 45 |ST.R9,#2_10...BE| 00002c70 51 09 6e 6f 5f 62 69 74 5f 31 0d 0a 09 4c 44 52 |Q.no_bit_1...LDR| 00002c80 42 09 52 30 2c 5b 52 31 32 5d 2c 23 31 0d 0a 09 |B.R0,[R12],#1...| 00002c90 53 54 52 42 09 52 30 2c 5b 52 31 31 5d 2c 23 31 |STRB.R0,[R11],#1| 00002ca0 0d 0a 09 4c 44 52 42 09 52 30 2c 5b 52 31 32 5d |...LDRB.R0,[R12]| 00002cb0 2c 23 31 0d 0a 09 53 54 52 42 09 52 30 2c 5b 52 |,#1...STRB.R0,[R| 00002cc0 31 31 5d 2c 23 31 0d 0a 6e 6f 5f 62 69 74 5f 31 |11],#1..no_bit_1| 00002cd0 0d 0a 3b 0d 0a 3b 20 4e 6f 77 20 77 65 20 6e 65 |..;..; Now we ne| 00002ce0 65 64 20 74 6f 20 61 6c 69 67 6e 20 52 31 32 20 |ed to align R12 | 00002cf0 73 6f 20 74 68 61 74 20 69 74 20 70 6f 69 6e 74 |so that it point| 00002d00 73 20 74 6f 20 74 68 65 20 6e 65 78 74 20 27 74 |s to the next 't| 00002d10 79 70 65 27 20 77 6f 72 64 2c 0d 0a 3b 20 73 69 |ype' word,..; si| 00002d20 6e 63 65 20 69 74 20 63 6f 75 6c 64 20 62 65 20 |nce it could be | 00002d30 73 74 72 61 67 67 6c 69 6e 67 20 61 74 20 61 20 |straggling at a | 00002d40 6e 6f 6e 20 77 6f 72 64 2d 61 6c 69 67 6e 65 64 |non word-aligned| 00002d50 20 70 6f 73 69 74 69 6f 6e 2e 0d 0a 3b 0d 0a 61 | position...;..a| 00002d60 6c 69 67 6e 5f 72 31 32 0d 0a 09 4c 44 4d 46 44 |lign_r12...LDMFD| 00002d70 09 52 31 33 21 2c 7b 52 30 2d 52 37 7d 09 09 3b |.R13!,{R0-R7}..;| 00002d80 20 52 65 73 74 6f 72 65 20 73 63 72 61 74 63 68 | Restore scratch| 00002d90 20 72 65 67 69 73 74 65 72 73 0d 0a 61 6c 69 67 | registers..alig| 00002da0 6e 5f 72 31 32 5f 6e 6f 5f 72 65 73 74 6f 72 65 |n_r12_no_restore| 00002db0 0d 0a 09 4c 44 52 09 52 33 2c 63 6f 6d 70 65 6e |...LDR.R3,compen| 00002dc0 73 61 74 65 5f 72 69 67 68 74 0d 0a 09 41 44 44 |sate_right...ADD| 00002dd0 09 52 31 32 2c 52 31 32 2c 52 33 0d 0a 09 4d 4f |.R12,R12,R3...MO| 00002de0 56 09 52 33 2c 23 30 0d 0a 09 53 54 52 09 52 33 |V.R3,#0...STR.R3| 00002df0 2c 63 6f 6d 70 65 6e 73 61 74 65 5f 72 69 67 68 |,compensate_righ| 00002e00 74 0d 0a 09 41 44 44 09 52 31 32 2c 52 31 32 2c |t...ADD.R12,R12,| 00002e10 23 33 0d 0a 09 42 49 43 09 52 31 32 2c 52 31 32 |#3...BIC.R12,R12| 00002e20 2c 23 33 0d 0a 6e 6f 5f 61 6c 69 67 6e 0d 0a 09 |,#3..no_align...| 00002e30 42 09 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 6e 65 |B.next_scan_line| 00002e40 5f 62 69 74 0d 0a 66 69 6e 69 73 68 65 64 5f 70 |_bit..finished_p| 00002e50 6c 6f 74 0d 0a 09 4c 44 4d 46 44 09 52 31 33 21 |lot...LDMFD.R13!| 00002e60 2c 7b 52 30 2d 52 31 32 2c 50 43 7d 5e 0d 0a 3b |,{R0-R12,PC}^..;| 00002e70 0d 0a 3b 20 54 68 69 73 20 73 68 6f 75 6c 64 20 |..; This should | 00002e80 6e 65 76 65 72 20 68 61 70 70 65 6e 20 3a 2d 29 |never happen :-)| 00002e90 0d 0a 3b 0d 0a 75 68 5f 6f 68 0d 0a 09 41 44 52 |..;..uh_oh...ADR| 00002ea0 09 52 30 2c 65 72 72 6f 72 0d 0a 09 53 57 49 09 |.R0,error...SWI.| 00002eb0 26 32 42 20 3b 20 4f 53 5f 47 65 6e 65 72 61 74 |&2B ; OS_Generat| 00002ec0 65 45 72 72 6f 72 0d 0a 0d 0a 65 72 72 6f 72 09 |eError....error.| 00002ed0 26 20 30 0d 0a 09 44 43 42 20 22 54 79 70 65 20 |& 0...DCB "Type | 00002ee0 77 6f 72 64 20 6f 75 74 20 6f 66 20 72 61 6e 67 |word out of rang| 00002ef0 65 20 28 30 2d 32 29 22 2c 30 0d 0a 09 41 4c 49 |e (0-2)",0...ALI| 00002f00 47 4e 0d 0a 0d 0a 6c 61 73 74 5f 79 09 09 09 26 |GN....last_y...&| 00002f10 20 30 0d 0a 66 69 72 73 74 5f 78 09 09 09 26 20 | 0..first_x...& | 00002f20 30 0d 0a 6e 65 78 74 5f 73 63 61 6e 5f 6c 69 6e |0..next_scan_lin| 00002f30 65 5f 61 64 64 72 65 73 73 09 26 20 30 0d 0a 6e |e_address.& 0..n| 00002f40 65 78 74 5f 73 63 61 6e 5f 6c 69 6e 65 5f 70 74 |ext_scan_line_pt| 00002f50 72 09 26 20 30 0d 0a 63 6f 6d 70 65 6e 73 61 74 |r.& 0..compensat| 00002f60 65 5f 72 69 67 68 74 09 26 20 30 0d 0a 0d 0a 20 |e_right.& 0.... | 00002f70 45 4e 44 0d 0a |END..| 00002f75