Home » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_55.ADF » V/+STARS
V/+STARS
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 » Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_55.ADF |
Filename: | V/+STARS |
Read OK: | ✔ |
File size: | 0A1B bytes |
Load address: | 2B204556 |
Exec address: | 52415453 |
Duplicates
There are 3 duplicate copies of this file in the archive:
- AEW website » eug » eug_3_5_discs_Eug-55_A-EUG55.adf » V/+STARS
- AEW website » eug » eug_5_25_discs_Eug-55_D-EUG55.dsd » V.+STARS
- Personal collection » Acorn ADFS disks » Electron_User_Group » EUG_55.ADF » V/+STARS
- Personal collection » Acorn ADFS disks » Greaseweazled » adfs_EUG_55.adf » V/+STARS
File contents
SCROLLING STARS DEMO Chris Dewhurst THIS file explains the code to the short assembly language utility "U.STARS" present on this disk, which creates a backdrop of scrolling stars. The 'stars' are really moving white dots, but the effect is impressive, and it's easier to achieve than you might think. We first of all set up a table of 30 addresses in the range &3000- &7FFF. That is to say, choose some random two-byte pointers into the Mode 2 screen. This is done in lines 570-610; the addresses are held at TABLE. The machine code routine BACKDROP EORs 21 (the pixel code for black- white in Mode 2) into each of the addresses. The routine SCROLL then moves each address down the screen by one pixel before redrawing the screen. But there are two things to watch out for: 1. If the star's address is the bottom row of a character row, then it needs to be changed to the top row of the next character row. We detect this by ANDing the low byte of the address with 7 and then CoMParing it with 7. If the result is 7, then &278 must be added to the address. For example, the low byte of &3007 is &07, &07 AND 7 = 7, so &3007 + &278 = &327F, and because all addresses are INCremented by one, &327F + 1 = &3280, the address of the second character row in Mode 2. 2. The star's address may have gone off the bottom of the screen, i.e. it's bigger than &7FFF. The way to check this is to examine the state of the Negative flag after the addition of &278. It will set if the high byte if &80 or more - i.e. the address is &8000 or greater - because in "two's complement" arithmetic a number above &7F is a negative number. We then 'wrap around' the address to the top of the screen by subtracting &50 (the Mode 2 screen is &5000 bytes big). If the result wasn't bigger than &80, the BPL CONT2 skips this substraction. So why is the instruction SBC #&4F and not SBC #&50? Well, subtracting one less than is necessary saves an SEC instruction. This all adds up to a short and efficient routine, only 135 bytes long including the table of addresses, that you could include in your games programs. One alteration you could make is to have coloured stars by using the X register to derive the colour. Christopher Dewhurst 10 September, 2000 EUG #55
00000000 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000010 20 20 20 20 20 20 20 20 20 53 43 52 4f 4c 4c 49 | SCROLLI| 00000020 4e 47 20 53 54 41 52 53 20 44 45 4d 4f 0d 20 20 |NG STARS DEMO. | 00000030 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000040 20 20 20 20 20 20 20 20 20 20 43 68 72 69 73 20 | Chris | 00000050 44 65 77 68 75 72 73 74 0d 0d 54 48 49 53 20 66 |Dewhurst..THIS f| 00000060 69 6c 65 20 65 78 70 6c 61 69 6e 73 20 74 68 65 |ile explains the| 00000070 20 63 6f 64 65 20 74 6f 20 74 68 65 20 73 68 6f | code to the sho| 00000080 72 74 20 61 73 73 65 6d 62 6c 79 20 6c 61 6e 67 |rt assembly lang| 00000090 75 61 67 65 20 75 74 69 6c 69 74 79 0d 22 55 2e |uage utility."U.| 000000a0 53 54 41 52 53 22 20 70 72 65 73 65 6e 74 20 6f |STARS" present o| 000000b0 6e 20 74 68 69 73 20 64 69 73 6b 2c 20 77 68 69 |n this disk, whi| 000000c0 63 68 20 63 72 65 61 74 65 73 20 61 20 62 61 63 |ch creates a bac| 000000d0 6b 64 72 6f 70 20 6f 66 20 73 63 72 6f 6c 6c 69 |kdrop of scrolli| 000000e0 6e 67 0d 73 74 61 72 73 2e 20 54 68 65 20 27 73 |ng.stars. The 's| 000000f0 74 61 72 73 27 20 61 72 65 20 72 65 61 6c 6c 79 |tars' are really| 00000100 20 6d 6f 76 69 6e 67 20 77 68 69 74 65 20 64 6f | moving white do| 00000110 74 73 2c 20 62 75 74 20 74 68 65 20 65 66 66 65 |ts, but the effe| 00000120 63 74 20 69 73 20 0d 69 6d 70 72 65 73 73 69 76 |ct is .impressiv| 00000130 65 2c 20 61 6e 64 20 69 74 27 73 20 65 61 73 69 |e, and it's easi| 00000140 65 72 20 74 6f 20 61 63 68 69 65 76 65 20 74 68 |er to achieve th| 00000150 61 6e 20 79 6f 75 20 6d 69 67 68 74 20 74 68 69 |an you might thi| 00000160 6e 6b 2e 0d 20 20 20 57 65 20 66 69 72 73 74 20 |nk.. We first | 00000170 6f 66 20 61 6c 6c 20 73 65 74 20 75 70 20 61 20 |of all set up a | 00000180 74 61 62 6c 65 20 6f 66 20 33 30 20 61 64 64 72 |table of 30 addr| 00000190 65 73 73 65 73 20 69 6e 20 74 68 65 20 72 61 6e |esses in the ran| 000001a0 67 65 20 26 33 30 30 30 2d 0d 26 37 46 46 46 2e |ge &3000-.&7FFF.| 000001b0 20 54 68 61 74 20 69 73 20 74 6f 20 73 61 79 2c | That is to say,| 000001c0 20 63 68 6f 6f 73 65 20 73 6f 6d 65 20 72 61 6e | choose some ran| 000001d0 64 6f 6d 20 74 77 6f 2d 62 79 74 65 20 70 6f 69 |dom two-byte poi| 000001e0 6e 74 65 72 73 20 69 6e 74 6f 20 74 68 65 0d 4d |nters into the.M| 000001f0 6f 64 65 20 32 20 73 63 72 65 65 6e 2e 20 54 68 |ode 2 screen. Th| 00000200 69 73 20 69 73 20 64 6f 6e 65 20 69 6e 20 6c 69 |is is done in li| 00000210 6e 65 73 20 35 37 30 2d 36 31 30 3b 20 74 68 65 |nes 570-610; the| 00000220 20 61 64 64 72 65 73 73 65 73 20 61 72 65 20 68 | addresses are h| 00000230 65 6c 64 20 61 74 0d 54 41 42 4c 45 2e 0d 20 20 |eld at.TABLE.. | 00000240 20 54 68 65 20 6d 61 63 68 69 6e 65 20 63 6f 64 | The machine cod| 00000250 65 20 72 6f 75 74 69 6e 65 20 42 41 43 4b 44 52 |e routine BACKDR| 00000260 4f 50 20 45 4f 52 73 20 32 31 20 28 74 68 65 20 |OP EORs 21 (the | 00000270 70 69 78 65 6c 20 63 6f 64 65 20 66 6f 72 20 62 |pixel code for b| 00000280 6c 61 63 6b 2d 0d 77 68 69 74 65 20 69 6e 20 4d |lack-.white in M| 00000290 6f 64 65 20 32 29 20 69 6e 74 6f 20 65 61 63 68 |ode 2) into each| 000002a0 20 6f 66 20 74 68 65 20 61 64 64 72 65 73 73 65 | of the addresse| 000002b0 73 2e 20 54 68 65 20 72 6f 75 74 69 6e 65 20 53 |s. The routine S| 000002c0 43 52 4f 4c 4c 20 74 68 65 6e 0d 6d 6f 76 65 73 |CROLL then.moves| 000002d0 20 65 61 63 68 20 61 64 64 72 65 73 73 20 64 6f | each address do| 000002e0 77 6e 20 74 68 65 20 73 63 72 65 65 6e 20 62 79 |wn the screen by| 000002f0 20 6f 6e 65 20 70 69 78 65 6c 20 62 65 66 6f 72 | one pixel befor| 00000300 65 20 72 65 64 72 61 77 69 6e 67 20 74 68 65 0d |e redrawing the.| 00000310 73 63 72 65 65 6e 2e 20 42 75 74 20 74 68 65 72 |screen. But ther| 00000320 65 20 61 72 65 20 74 77 6f 20 74 68 69 6e 67 73 |e are two things| 00000330 20 74 6f 20 77 61 74 63 68 20 6f 75 74 20 66 6f | to watch out fo| 00000340 72 3a 0d 0d 20 20 20 31 2e 20 49 66 20 74 68 65 |r:.. 1. If the| 00000350 20 73 74 61 72 27 73 20 61 64 64 72 65 73 73 20 | star's address | 00000360 69 73 20 74 68 65 20 62 6f 74 74 6f 6d 20 72 6f |is the bottom ro| 00000370 77 20 6f 66 20 61 20 63 68 61 72 61 63 74 65 72 |w of a character| 00000380 20 72 6f 77 2c 20 74 68 65 6e 0d 20 20 20 20 20 | row, then. | 00000390 20 69 74 20 6e 65 65 64 73 20 74 6f 20 62 65 20 | it needs to be | 000003a0 63 68 61 6e 67 65 64 20 74 6f 20 74 68 65 20 74 |changed to the t| 000003b0 6f 70 20 72 6f 77 20 6f 66 20 74 68 65 20 6e 65 |op row of the ne| 000003c0 78 74 20 63 68 61 72 61 63 74 65 72 20 72 6f 77 |xt character row| 000003d0 2e 20 0d 20 20 20 20 20 20 57 65 20 64 65 74 65 |. . We dete| 000003e0 63 74 20 74 68 69 73 20 62 79 20 41 4e 44 69 6e |ct this by ANDin| 000003f0 67 20 74 68 65 20 6c 6f 77 20 62 79 74 65 20 6f |g the low byte o| 00000400 66 20 74 68 65 20 61 64 64 72 65 73 73 20 77 69 |f the address wi| 00000410 74 68 20 37 20 61 6e 64 20 0d 20 20 20 20 20 20 |th 7 and . | 00000420 74 68 65 6e 20 43 6f 4d 50 61 72 69 6e 67 20 69 |then CoMParing i| 00000430 74 20 77 69 74 68 20 37 2e 20 49 66 20 74 68 65 |t with 7. If the| 00000440 20 72 65 73 75 6c 74 20 69 73 20 37 2c 20 74 68 | result is 7, th| 00000450 65 6e 20 26 32 37 38 20 6d 75 73 74 20 62 65 20 |en &278 must be | 00000460 0d 20 20 20 20 20 20 61 64 64 65 64 20 74 6f 20 |. added to | 00000470 74 68 65 20 61 64 64 72 65 73 73 2e 20 46 6f 72 |the address. For| 00000480 20 65 78 61 6d 70 6c 65 2c 20 74 68 65 20 6c 6f | example, the lo| 00000490 77 20 62 79 74 65 20 6f 66 20 26 33 30 30 37 20 |w byte of &3007 | 000004a0 69 73 20 26 30 37 2c 0d 20 20 20 20 20 20 26 30 |is &07,. &0| 000004b0 37 20 41 4e 44 20 37 20 3d 20 37 2c 20 73 6f 20 |7 AND 7 = 7, so | 000004c0 26 33 30 30 37 20 2b 20 26 32 37 38 20 3d 20 26 |&3007 + &278 = &| 000004d0 33 32 37 46 2c 20 61 6e 64 20 62 65 63 61 75 73 |327F, and becaus| 000004e0 65 20 61 6c 6c 20 61 64 64 72 65 73 73 65 73 0d |e all addresses.| 000004f0 20 20 20 20 20 20 61 72 65 20 49 4e 43 72 65 6d | are INCrem| 00000500 65 6e 74 65 64 20 62 79 20 6f 6e 65 2c 20 26 33 |ented by one, &3| 00000510 32 37 46 20 2b 20 31 20 3d 20 26 33 32 38 30 2c |27F + 1 = &3280,| 00000520 20 74 68 65 20 61 64 64 72 65 73 73 20 6f 66 20 | the address of | 00000530 74 68 65 0d 20 20 20 20 20 20 73 65 63 6f 6e 64 |the. second| 00000540 20 63 68 61 72 61 63 74 65 72 20 72 6f 77 20 69 | character row i| 00000550 6e 20 4d 6f 64 65 20 32 2e 0d 0d 20 20 20 32 2e |n Mode 2... 2.| 00000560 20 54 68 65 20 73 74 61 72 27 73 20 61 64 64 72 | The star's addr| 00000570 65 73 73 20 6d 61 79 20 68 61 76 65 20 67 6f 6e |ess may have gon| 00000580 65 20 6f 66 66 20 74 68 65 20 62 6f 74 74 6f 6d |e off the bottom| 00000590 20 6f 66 20 74 68 65 20 73 63 72 65 65 6e 2c 20 | of the screen, | 000005a0 0d 20 20 20 20 20 20 69 2e 65 2e 20 69 74 27 73 |. i.e. it's| 000005b0 20 62 69 67 67 65 72 20 74 68 61 6e 20 26 37 46 | bigger than &7F| 000005c0 46 46 2e 20 54 68 65 20 77 61 79 20 74 6f 20 63 |FF. The way to c| 000005d0 68 65 63 6b 20 74 68 69 73 20 69 73 20 74 6f 20 |heck this is to | 000005e0 65 78 61 6d 69 6e 65 0d 20 20 20 20 20 20 74 68 |examine. th| 000005f0 65 20 73 74 61 74 65 20 6f 66 20 74 68 65 20 4e |e state of the N| 00000600 65 67 61 74 69 76 65 20 66 6c 61 67 20 61 66 74 |egative flag aft| 00000610 65 72 20 74 68 65 20 61 64 64 69 74 69 6f 6e 20 |er the addition | 00000620 6f 66 20 26 32 37 38 2e 20 49 74 20 77 69 6c 6c |of &278. It will| 00000630 0d 20 20 20 20 20 20 73 65 74 20 69 66 20 74 68 |. set if th| 00000640 65 20 68 69 67 68 20 62 79 74 65 20 69 66 20 26 |e high byte if &| 00000650 38 30 20 6f 72 20 6d 6f 72 65 20 2d 20 69 2e 65 |80 or more - i.e| 00000660 2e 20 74 68 65 20 61 64 64 72 65 73 73 20 69 73 |. the address is| 00000670 20 26 38 30 30 30 20 6f 72 0d 20 20 20 20 20 20 | &8000 or. | 00000680 67 72 65 61 74 65 72 20 2d 20 62 65 63 61 75 73 |greater - becaus| 00000690 65 20 69 6e 20 22 74 77 6f 27 73 20 63 6f 6d 70 |e in "two's comp| 000006a0 6c 65 6d 65 6e 74 22 20 61 72 69 74 68 6d 65 74 |lement" arithmet| 000006b0 69 63 20 61 20 6e 75 6d 62 65 72 20 61 62 6f 76 |ic a number abov| 000006c0 65 0d 20 20 20 20 20 20 26 37 46 20 69 73 20 61 |e. &7F is a| 000006d0 20 6e 65 67 61 74 69 76 65 20 6e 75 6d 62 65 72 | negative number| 000006e0 2e 20 57 65 20 74 68 65 6e 20 27 77 72 61 70 20 |. We then 'wrap | 000006f0 61 72 6f 75 6e 64 27 20 74 68 65 20 61 64 64 72 |around' the addr| 00000700 65 73 73 20 74 6f 20 74 68 65 0d 20 20 20 20 20 |ess to the. | 00000710 20 74 6f 70 20 6f 66 20 74 68 65 20 73 63 72 65 | top of the scre| 00000720 65 6e 20 62 79 20 73 75 62 74 72 61 63 74 69 6e |en by subtractin| 00000730 67 20 26 35 30 20 28 74 68 65 20 4d 6f 64 65 20 |g &50 (the Mode | 00000740 32 20 73 63 72 65 65 6e 20 69 73 20 26 35 30 30 |2 screen is &500| 00000750 30 0d 20 20 20 20 20 20 62 79 74 65 73 20 62 69 |0. bytes bi| 00000760 67 29 2e 20 49 66 20 74 68 65 20 72 65 73 75 6c |g). If the resul| 00000770 74 20 77 61 73 6e 27 74 20 62 69 67 67 65 72 20 |t wasn't bigger | 00000780 74 68 61 6e 20 26 38 30 2c 20 74 68 65 20 42 50 |than &80, the BP| 00000790 4c 20 43 4f 4e 54 32 0d 20 20 20 20 20 20 73 6b |L CONT2. sk| 000007a0 69 70 73 20 74 68 69 73 20 73 75 62 73 74 72 61 |ips this substra| 000007b0 63 74 69 6f 6e 2e 20 53 6f 20 77 68 79 20 69 73 |ction. So why is| 000007c0 20 74 68 65 20 69 6e 73 74 72 75 63 74 69 6f 6e | the instruction| 000007d0 20 53 42 43 20 23 26 34 46 20 61 6e 64 20 0d 20 | SBC #&4F and . | 000007e0 20 20 20 20 20 6e 6f 74 20 53 42 43 20 23 26 35 | not SBC #&5| 000007f0 30 3f 20 57 65 6c 6c 2c 20 73 75 62 74 72 61 63 |0? Well, subtrac| 00000800 74 69 6e 67 20 6f 6e 65 20 6c 65 73 73 20 74 68 |ting one less th| 00000810 61 6e 20 69 73 20 6e 65 63 65 73 73 61 72 79 20 |an is necessary | 00000820 73 61 76 65 73 20 0d 20 20 20 20 20 20 61 6e 20 |saves . an | 00000830 53 45 43 20 69 6e 73 74 72 75 63 74 69 6f 6e 2e |SEC instruction.| 00000840 0d 0d 54 68 69 73 20 61 6c 6c 20 61 64 64 73 20 |..This all adds | 00000850 75 70 20 74 6f 20 61 20 73 68 6f 72 74 20 61 6e |up to a short an| 00000860 64 20 65 66 66 69 63 69 65 6e 74 20 72 6f 75 74 |d efficient rout| 00000870 69 6e 65 2c 20 6f 6e 6c 79 20 31 33 35 20 62 79 |ine, only 135 by| 00000880 74 65 73 20 6c 6f 6e 67 0d 69 6e 63 6c 75 64 69 |tes long.includi| 00000890 6e 67 20 74 68 65 20 74 61 62 6c 65 20 6f 66 20 |ng the table of | 000008a0 61 64 64 72 65 73 73 65 73 2c 20 74 68 61 74 20 |addresses, that | 000008b0 79 6f 75 20 63 6f 75 6c 64 20 69 6e 63 6c 75 64 |you could includ| 000008c0 65 20 69 6e 20 79 6f 75 72 20 67 61 6d 65 73 0d |e in your games.| 000008d0 70 72 6f 67 72 61 6d 73 2e 20 4f 6e 65 20 61 6c |programs. One al| 000008e0 74 65 72 61 74 69 6f 6e 20 79 6f 75 20 63 6f 75 |teration you cou| 000008f0 6c 64 20 6d 61 6b 65 20 69 73 20 74 6f 20 68 61 |ld make is to ha| 00000900 76 65 20 63 6f 6c 6f 75 72 65 64 20 73 74 61 72 |ve coloured star| 00000910 73 20 62 79 0d 75 73 69 6e 67 20 74 68 65 20 58 |s by.using the X| 00000920 20 72 65 67 69 73 74 65 72 20 74 6f 20 64 65 72 | register to der| 00000930 69 76 65 20 74 68 65 20 63 6f 6c 6f 75 72 2e 0d |ive the colour..| 00000940 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000970 20 20 20 20 43 68 72 69 73 74 6f 70 68 65 72 20 | Christopher | 00000980 44 65 77 68 75 72 73 74 0d 20 20 20 20 20 20 20 |Dewhurst. | 00000990 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 000009b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 31 | 1| 000009c0 30 20 53 65 70 74 65 6d 62 65 72 2c 20 32 30 30 |0 September, 200| 000009d0 30 0d 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |0. | 000009e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 00000a10 20 20 20 45 55 47 20 23 35 35 0d | EUG #55.| 00000a1b