1 ; original code (c) Nick Fleming, 2000; all rights reserved
2 ; modified and rewritten a little by Ketmar // Invisible Vector
4 ; start by initialising the
5 ; system variables area
15 defb 0xF5,0xC5,0x01,0xFD,0x7F,0x3A,0x5C,0x5B
16 defb 0xEE,0x10,0xF3,0X32,0x5C,0x5B,0xED,0x79
17 defb 0xFB,0xC1,0xF1,0xC9,0xcd,0x00,0x5B,0xE5
18 defb 0x2A,0x5A,0x5B,0xE3,0xC9,0xF3,0x3A,0x5C
19 defb 0x5B,0xE6,0xEF,0x32,0x5C,0x5B,0x01,0xFD
20 defb 0x7F,0xED,0x79,0xFB,0xC3,0xC3,0x00,0x21
21 defb 0xD8,0x06,0x18,0x03,0x21,0xCA,0x07,0x08
22 defb 0x01,0xFD,0x7F,0x3A,0x5c,0x5B,0xF5,0xE6
23 defb 0xEF,0xF3,0x32,0x5C,0x5B,0xED,0x79,0xC3
24 defb 0xE6,0x05,0x08,0xF1,0x01,0xFD,0x7f,0xF3
25 defb 0x32,0x5C,0x5B,0xED,0x79,0xFB,0x08,0xC9
45 defb 0x00,0x00,0x00,0x00,0x00 ; 5B6E
52 defb 0x00,0x00,0x00,0x00,0x00,0x58,0xFF,0xEC
53 defb 0xEB,0xEC,0x2B,0x01,0x01,0x4C,0x00,0x00
196 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
201 ; BC,DE,HL,AF -- dead
222 ; ==============================================
223 ; Screen Address Routines
224 ; ==============================================
226 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
227 ; Row Table Routines - generate a table of
228 ; addresses to allow easy working out of
246 screenRowTable: defs 200*2,0
249 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
253 ; HL: scrAddrNext -- next y line
269 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
273 ; HL: scrAddrNext -- next y line
289 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
290 ; moves screen address down one entire character (8 pixels)
291 ; on entry: hl = screen address
292 ; on exit : hl = screen address, one character below
303 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
304 ; moves screen address up one entire character (8 pixels)
305 ; on entry: hl = screen address
306 ; on exit : hl = screen address, one character above
317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
318 ; converts a screen address to an attribute address
319 ; on entry: de = screen address
320 ; on exit : de = attr address
331 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
332 ; converts an attribute address to screen address
333 ; on entry: de = attribute address
334 ; on exit : de = screen address
346 ; ==================================================
347 ; Spectrum GFX Library Routines:
353 ; =================================================
355 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
356 ; call with bc = x, de = y
358 ; do tests to see if pixel is on screen
369 ; calculate row to start drawing at
395 add hl,de ; hl = screen address to draw pixel at
403 defb 0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01
405 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
406 ; call with a = ascii character code
407 ; hl = screen address
409 sub 32 ; 32 = space = first char = 0, so sub 32!
413 add hl,hl ; multiply by 8.
419 ex de,hl ; de = address of char data.
431 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
432 ; call with de = address of string
433 ; hl = screen address
434 ; hl should be on a boundry so that (y&7) = 0
435 ; (ie lowest 3 bits of h should be 0)
451 ; ----------------------------------------------------------------
452 ; sprite drawing routines
453 ; ----------------------------------------------------------------
455 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
456 ; call with hl pointing to a sprite record.
458 ; Draws a 16 pixel wide sprite (variable height)
459 ; directly onto the spectrum screen. In order to achieve
460 ; 'smooth' graphics, the sprite is erased and redrawn
461 ; a line at a time. Although this may seem wasteful, it
462 ; does appear to work well as glitching and flicker are
465 ; A sprite record has the following format:
468 ; 0 Sprite id (0 = sprite disabled)
469 ; 1 Sprite Status (0 = off, 1 = on, 2 = erase (no drawing))
474 ; 8-9 Last Screen Address
475 ; 10-11 Graphic Data Address
476 ; 12-13 Last Graphic Address
485 inc hl ; for now, skip status
488 ld a,(hl) ; store colour for later
498 ld (_Sprite_Attr_Height),a
502 ld b,(hl) ; assume b = 0 for now
506 ld (_Sprite_Attr_Width),a
508 ld a,(hl) ; a = last x
515 ; generate screen address without using tables :)
516 ; store result in hl?
539 ld l,a ; at this point hl = screen address
541 ld (_Sprite_ScreenAddr),hl
543 ex de,hl ; store newly calculated screen address in de
545 ; ---- Set the attributes (rough experimental version) ----
546 ; for now it draws attrs only for 16x16 sprites
553 ld a,(_Sprite_Attr_Width)
555 jp nz,.draw_wide_attr
570 ld a,(_Sprite_Attr_Height)
612 ; ----- calculate rotate addresses -----
623 ld (Sprite_RotateAddr),bc
626 ld hl,LastRotateTable
636 ld (Sprite_LastRotateAddr),bc
639 pop hl ; hl = last screen address item (in sprite data)
641 ld c,(hl) ; get last screen address and store new one in its place.
646 inc hl ; bc = last screen address.
648 ld (_Sprite_LastScreenAddr),bc
650 ld e,(hl) ; get new graphic address
655 ld c,(hl) ; get last graphic address and store new one in its place
663 ld (_Sprite_Last_Gfx),bc
665 ld a,(hl) ; get sprite height + store
668 ; snippet : load up gfx data.
673 ; load up registers with a line of sprite graphic data
681 ex de,hl ; a,h,l = gfx addr
683 ; load up alternative registers with a line of sprite graphic data to erase with
687 ld hl,(_Sprite_Last_Gfx)
693 ld (_Sprite_Last_Gfx),hl
694 ex de,hl ; a',h',l' = gfx addr
699 ; push rotate address onto stack then
700 ; do ret - cheats way of doing jp (bc)
701 ; (which doesnt exist..)
704 ld bc,(Sprite_RotateAddr)
707 ld de,(_Sprite_ScreenAddr)
712 ld (_Sprite_ScreenAddr),de
715 ld bc,(Sprite_LastRotateAddr)
718 ld de,(_Sprite_LastScreenAddr)
723 ld (_Sprite_LastScreenAddr),de
733 ; Draw left-rotated line of sprite data.
734 ; Call with h and l holding the sprite data to display.
735 ; de = screen address to draw at.
754 ;ld hl,(_Sprite_ScreenAddr)
772 ;ld (_Sprite_ScreenAddr),hl
775 ; Draw right-rotated line of sprite data
776 ; Call with h and l holding the sprite data to display.
800 ld b,a ; rotate so order is a,d,e as with left rotate.
805 ;ld hl,(_Sprite_ScreenAddr)
823 ;ld (_Sprite_ScreenAddr),hl
830 DEFW DrawSubRotRight1
831 DEFW DrawSubRotRight2
832 DEFW DrawSubRotRight3
848 ; memory stores to make life easier.
850 Sprite_RotateAddr: DEFW 0 ; address to 'jump to' to do rotating with
851 Sprite_LastRotateAddr: DEFW DrawSubRotNo2 ; address to 'jump to' to do rotating with
853 _Sprite_Attr_Width: DEFB 0 ; 0 -> width = 2, otherwise = 3
854 _Sprite_Attr_Height: DEFB 0 ; 0 -> height= 2 otherwise = 3.
857 _Sprite_ScreenAddr: DEFW 0
858 _Sprite_LastScreenAddr: DEFW 0
859 _Sprite_Gfx: DEFW 0 ; address of sprite data
860 _Sprite_Last_Gfx: DEFW 0 ; address of 'old' sprite data
861 _SpriteLoop: DEFW 0 ; sprite loop size.
863 ; ---------------------------------------------------------------
864 ; End of Sprite Drawing Routines.
865 ; ---------------------------------------------------------------
867 ; ===========================================
868 ; Keyboard Reading Routines.
869 ; ===========================================
870 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
871 ; carry set if no key pressed,
872 ; otherwise returns ascii key code in A
874 ; ** under construction **
918 defm "*ZXCVASDFGQWERT1234509876POIUY+LKJH;#MNB"
920 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
922 defb %00000000 ; space
1039 defb %00000000 ; - (minus)
1048 defb %00000000 ; . (full stop)
1057 defb %00000000 ; / (forward slash)
1156 defb %00000000 ; : (colon)
1165 defb %00000000 ; ; (semi-colon)
1462 defb %00000000 ; '\'
1489 defb %00000000 ; _ (underscore ?)
1498 defb %00000000 ; ` (funny quote..)
1768 defb %00000000 ; ~ (squiggle!)
1778 ; 0 Sprite id (0 = sprite disabled)
1779 ; 1 Sprite Status (0 = off, 1 = on, 2 = erase (no drawing))
1784 ; 8-9 Last Screen Address
1785 ; 10-11 Graphic Data Address
1786 ; 12-13 Last Graphic Address
1793 DEFB 1 ; Sprite Status
1794 DEFB 65 ; Sprite Colour
1795 SPRY1: DEFW 40 ; Sprite Y
1796 SPRX1: DEFW 16 ; Sprite X
1798 DEFW 0 ; Last Screen Address
1799 DEFW ManWalkingRight0 ; Graphic Data Address.
1800 DEFW 32768 ; Last Graphic Address
1801 DEFB 24 ; Sprite Height
1807 DEFB 1 ; Sprite Status
1808 DEFB 66 ; Sprite Colour
1809 SPRY2: DEFW 20 ; Sprite Y
1810 SPRX2: DEFW 16 ; Sprite X
1812 DEFW 0 ; Last Screen Address
1813 DEFW AlienGFX0 ; Graphic Data Address.
1814 DEFW 32768 ; Last Graphic Address
1815 DEFB 16 ; Sprite Height
1821 DEFB 1 ; Sprite Status
1822 DEFB 67 ; Sprite Colour
1823 SPRY3: DEFW 70 ; Sprite Y
1824 SPRX3: DEFW 80 ; Sprite X
1826 DEFW 0 ; Last Screen Address
1827 DEFW AlienGFX0 ; Graphic Data Address.
1828 DEFW 32768 ; Last Graphic Address
1829 DEFB 16 ; Sprite Height
1835 DEFB 1 ; Sprite Status
1836 DEFB 68 ; Sprite Colour
1837 SPRY4: DEFW 20 ; Sprite Y
1838 SPRX4: DEFW 170 ; Sprite X
1840 DEFW 0 ; Last Screen Address
1841 DEFW AlienGFX1 ; Graphic Data Address.
1842 DEFW 32768 ; Last Graphic Address
1843 DEFB 16 ; Sprite Height
1849 DEFB 1 ; Sprite Status
1850 DEFB 69 ; Sprite Colour
1851 SPRY5: DEFW 20 ; Sprite Y
1852 SPRX5: DEFW 170 ; Sprite X
1854 DEFW 0 ; Last Screen Address
1855 DEFW AlienGFX1 ; Graphic Data Address.
1856 DEFW 32768 ; Last Graphic Address
1857 DEFB 16 ; Sprite Height
1863 DEFB 1 ; Sprite Status
1864 DEFB 70 ; Sprite Colour
1865 SPRY6: DEFW 64 ; Sprite Y
1866 SPRX6: DEFW 64 ; Sprite X
1868 DEFW 0 ; Last Screen Address
1869 DEFW AlienGFX0 ; Graphic Data Address.
1870 DEFW 32768 ; Last Graphic Address
1871 DEFB 16 ; Sprite Height
1877 DEFB 1 ; Sprite Status
1878 DEFB 71 ; Sprite Colour
1879 SPRY7: DEFW 120 ; Sprite Y
1880 SPRX7: DEFW 0 ; Sprite X
1882 DEFW 0 ; Last Screen Address
1883 DEFW AlienGFX1 ; Graphic Data Address.
1884 DEFW 32768 ; Last Graphic Address
1885 DEFB 16 ; Sprite Height
1891 DEFB 1 ; Sprite Status
1892 DEFB 71 ; Sprite Colour
1893 SPRY8: DEFW 100 ; Sprite Y
1894 SPRX8: DEFW 224 ; Sprite X
1896 DEFW 0 ; Last Screen Address
1897 DEFW ManWalkingRight0 ; Graphic Data Address.
1898 DEFW 32768 ; Last Graphic Address
1899 DEFB 24 ; Sprite Height
1905 ; 24 pixels high, 16 pixels wide.
1906 ; note low and high bytes swapped !
1907 defr %0001111110000000
1908 defr %0011110001000000
1909 defr %1100001110000000
1910 defr %0011110000000000
1911 defr %0100001011000000
1912 defr %1011101010000000
1913 defr %0011101100110000
1914 defr %0111011111100000
1915 defr %0110001110000000
1916 defr %0001110000000000
1917 defr %0011111100000000
1918 defr %0011101100000000
1919 defr %0011100000000000
1920 defr %0011110000000000
1921 defr %0001101000000000
1922 defr %0010011100000000
1923 defr %0011101101000000
1924 defr %0001110011000000
1925 defr %0000111101100000
1926 defr %0010111011000000
1927 defr %0010111000000000
1928 defr %0010110000000000
1929 defr %0000001000000000
1930 defr %0001111100000000
1933 defr %0000001001000000
1934 defr %0000011100100000
1935 defr %0000111110010000
1936 defr %0000111110010000
1937 defr %0000000000000000
1938 defr %0111111111111010
1939 defr %1111111111111101
1940 defr %1111111111111101
1941 defr %0111111111111010
1942 defr %0000000000000000
1943 defr %0000011111100000
1944 defr %0000100000010000
1945 defr %0001000110001000
1946 defr %0010000000000100
1947 defr %1100000000000011
1948 defr %1100000000000011
1951 defr %1000001111000001
1952 defr %1110011111100111
1953 defr %0110111111110110
1954 defr %0001111111111000
1955 defr %0011111111111100
1956 defr %0111101111011110
1957 defr %1111110110111111
1958 defr %1111001001001111
1959 defr %0011001111001100
1960 defr %0001111111111000
1961 defr %0011011111101100
1962 defr %0110000110000110
1963 defr %1100000110000011
1964 defr %1100000110000011
1965 defr %0110000000000110
1966 defr %0001000000001000