junglejourney

changeset 12:398133d27070

Used 8x24 sized sprites for characters. Added placeholders for addresses in BASIC files. Added a test program for the character sprite plotting routine. Used a function to read sprites from files.
author David Boddie <david@boddie.org.uk>
date Tue Aug 09 01:40:46 2011 +0200
parents 4316cc634ab2
children af909a4a6266
files LOADER TESTSPRITES build.py images/left1.xpm images/left2.xpm makesprites.py mapcode.oph
diffstat 7 files changed, 110 insertions(+), 114 deletions(-) [+]
line diff
     1.1 --- a/LOADER	Mon Aug 08 23:14:12 2011 +0200
     1.2 +++ b/LOADER	Tue Aug 09 01:40:46 2011 +0200
     1.3 @@ -12,7 +12,7 @@
     1.4  ?&79=5
     1.5  
     1.6  REPEAT
     1.7 -CALL &1B1F
     1.8 +CALL &{addr}
     1.9  
    1.10  A% = GET
    1.11  IF A%=90 AND ?&79>0 THEN ?&79=?&79-1
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/TESTSPRITES	Tue Aug 09 01:40:46 2011 +0200
     2.3 @@ -0,0 +1,15 @@
     2.4 +AUTO
     2.5 +OSCLI("LOAD CODE")
     2.6 +OSCLI("LOAD CHARS")
     2.7 +
     2.8 +MODE 5
     2.9 +VDU 19,2,2;0;
    2.10 +VDU 19,3,3;0;
    2.11 +
    2.12 +PRINT TAB(0,3);
    2.13 +
    2.14 +?&70=0
    2.15 +?&71=&50
    2.16 +?&72=0
    2.17 +?&73=&58
    2.18 +CALL &{addr}
     3.1 --- a/build.py	Mon Aug 08 23:14:12 2011 +0200
     3.2 +++ b/build.py	Tue Aug 09 01:40:46 2011 +0200
     3.3 @@ -59,13 +59,15 @@
     3.4      
     3.5      system("ophis mapcode.oph CODE")
     3.6      code = open("CODE").read()
     3.7 -    files.append(("CODE", 0x1900, 0x1900, code))
     3.8 -
     3.9 +    code_start = 0x1900
    3.10 +    files.append(("CODE", code_start, code_start, code))
    3.11 +    
    3.12 +    addresses = []
    3.13      i = 0
    3.14      while i < len(code):
    3.15          if ord(code[i]) == 0x60:
    3.16              if i + 1 < len(code):
    3.17 -                print hex(i + 1)
    3.18 +                addresses.append(code_start + i + 1)
    3.19          i += 1
    3.20      
    3.21      data = makesprites.read_sprites(makesprites.chars)
    3.22 @@ -74,9 +76,13 @@
    3.23      data = makesprites.read_sprites(makesprites.tiles)
    3.24      files.append(("SPRITES", 0x5600, 0x5600, data))
    3.25      
    3.26 -    t = read_basic("LOADER")
    3.27 +    t = read_basic("LOADER").replace("{addr}", "%X" % addresses[-2])
    3.28 +    
    3.29      files.append(("LOADER", 0xffff0e00, 0xffff802b, t))
    3.30      
    3.31 +    t = read_basic("TESTSPRITES").replace("{addr}", "%X" % addresses[-1])
    3.32 +    files.append(("TEST", 0xffff0e00, 0xffff802b, t))
    3.33 +    
    3.34      u = UEFfile.UEFfile(creator = 'build.py '+version)
    3.35      u.minor = 6
    3.36      u.import_files(0, files)
     4.1 --- a/images/left1.xpm	Mon Aug 08 23:14:12 2011 +0200
     4.2 +++ b/images/left1.xpm	Tue Aug 09 01:40:46 2011 +0200
     4.3 @@ -1,31 +1,31 @@
     4.4  /* XPM */
     4.5  static char * left1_xpm[] = {
     4.6 -"12 24 4 1",
     4.7 +"8 24 4 1",
     4.8  " 	c None",
     4.9  ".	c #000000",
    4.10  "+	c #008000",
    4.11  "@	c #FFFF00",
    4.12 -"....++++....",
    4.13 -"...++++++...",
    4.14 -"...++++++...",
    4.15 -"..++++++++..",
    4.16 -"..++++++++..",
    4.17 -"...@@@@+@...",
    4.18 -"...@.@@+@...",
    4.19 -"..@@@@+@@...",
    4.20 -"...@@@+@....",
    4.21 -"....@@+@....",
    4.22 -"...+........",
    4.23 -"...+++++.++.",
    4.24 -"...++.++.+++",
    4.25 -"@+.++..++.++",
    4.26 -"@+.+++.++.+.",
    4.27 -".....++@@...",
    4.28 -"...+++.@@...",
    4.29 -"...+++++....",
    4.30 -"...++.+++...",
    4.31 -"...++.+++...",
    4.32 -"...+++.++...",
    4.33 -"............",
    4.34 -"..+++.++++..",
    4.35 -"..+++.++++.."};
    4.36 +"...+++..",
    4.37 +"..++.++.",
    4.38 +"..+++.+.",
    4.39 +".++++.++",
    4.40 +".+++++++",
    4.41 +"..@@@@+.",
    4.42 +"..@.@@+.",
    4.43 +".@@@@+@.",
    4.44 +"..@@@+..",
    4.45 +"...@@+..",
    4.46 +"..+++++.",
    4.47 +"..+++++.",
    4.48 +"..++.++.",
    4.49 +"@+++..++",
    4.50 +"@++++.++",
    4.51 +"..++++@@",
    4.52 +"......@@",
    4.53 +"..+++++.",
    4.54 +"..++.++.",
    4.55 +".+++.+++",
    4.56 +".++...++",
    4.57 +"........",
    4.58 +"+++..+++",
    4.59 +"+++..+++"};
     5.1 --- a/images/left2.xpm	Mon Aug 08 23:14:12 2011 +0200
     5.2 +++ b/images/left2.xpm	Tue Aug 09 01:40:46 2011 +0200
     5.3 @@ -1,31 +1,31 @@
     5.4  /* XPM */
     5.5  static char * left2_xpm[] = {
     5.6 -"12 24 4 1",
     5.7 +"8 24 4 1",
     5.8  " 	c None",
     5.9  ".	c #000000",
    5.10  "+	c #008000",
    5.11  "@	c #FFFF00",
    5.12 -"....++++....",
    5.13 -"...++++++...",
    5.14 -"...++++++...",
    5.15 -"..++++++++..",
    5.16 -"..++++++++..",
    5.17 -"...@@@@+@...",
    5.18 -"...@.@@+@...",
    5.19 -"..@@@@+@@...",
    5.20 -"...@@@+@....",
    5.21 -"....@@+@....",
    5.22 -"...+........",
    5.23 -"...+++++.++.",
    5.24 -"...+++++.++.",
    5.25 -"@+.++.++.++.",
    5.26 -"@+.++.++.++.",
    5.27 -"......@@....",
    5.28 -"...+++@@....",
    5.29 -"...+++.+....",
    5.30 -"...+++.+....",
    5.31 -"...+++.+....",
    5.32 -"...++++.....",
    5.33 -"........++..",
    5.34 -"..+++++.++..",
    5.35 -"..+++++.++.."};
    5.36 +"...+++..",
    5.37 +"..++.++.",
    5.38 +"..+++.+.",
    5.39 +".++++.++",
    5.40 +".+++++++",
    5.41 +"..@@@@+.",
    5.42 +"..@.@@+.",
    5.43 +".@@@@+@.",
    5.44 +"..@@@+..",
    5.45 +"...@@+..",
    5.46 +"..+++++.",
    5.47 +"..+++++.",
    5.48 +"..++.++.",
    5.49 +"@+++.++.",
    5.50 +"@+++.++.",
    5.51 +"..++.@@.",
    5.52 +".....@@.",
    5.53 +"..++++..",
    5.54 +"..++++..",
    5.55 +"...+++..",
    5.56 +"...+++..",
    5.57 +"........",
    5.58 +"..++++..",
    5.59 +"..++++.."};
     6.1 --- a/makesprites.py	Mon Aug 08 23:14:12 2011 +0200
     6.2 +++ b/makesprites.py	Tue Aug 09 01:40:46 2011 +0200
     6.3 @@ -17,6 +17,29 @@
     6.4  along with this program.  If not, see <http://www.gnu.org/licenses/>.
     6.5  """
     6.6  
     6.7 +def read_xpm(path):
     6.8 +
     6.9 +    lines = open(path).readlines()
    6.10 +    char_lines = filter(lambda line: line.startswith('"'), lines)
    6.11 +    strings = map(lambda line: line.strip()[1:-2], char_lines)
    6.12 +    strings[-1] = strings[-1][:-1]
    6.13 +    
    6.14 +    width, height, colours = map(int, strings[0].split()[:3])
    6.15 +    strings = strings[-height:]
    6.16 +    
    6.17 +    symbols = [(".", 0), ("+", 2), ("@", 3)]
    6.18 +    data = []
    6.19 +    
    6.20 +    for s in strings:
    6.21 +    
    6.22 +        for symbol, value in symbols:
    6.23 +            s = s.replace(symbol, str(value))
    6.24 +        
    6.25 +        data.append(s)
    6.26 +    
    6.27 +    return data
    6.28 +
    6.29 +
    6.30  tiles = [
    6.31          ("0000000000000000",)*24,
    6.32          ("0002020020000200",
    6.33 @@ -93,56 +116,8 @@
    6.34           "0000220000002000")
    6.35      ]
    6.36  
    6.37 -chars = [
    6.38 -    ("000022220000",
    6.39 -     "000202022000",
    6.40 -     "000020202000",
    6.41 -     "002202020200",
    6.42 -     "002020202200",
    6.43 -     "000333323000",
    6.44 -     "000303323000",
    6.45 -     "003333233000",
    6.46 -     "000333230000",
    6.47 -     "000033230000",
    6.48 -     "000200000000",
    6.49 -     "000022220220",
    6.50 -     "000200220222",
    6.51 -     "322020022022",
    6.52 -     "320202022020",
    6.53 -     "000002233000",
    6.54 -     "000202033000",
    6.55 -     "000020200000",
    6.56 -     "000200020000",
    6.57 -     "000020202000",
    6.58 -     "000202020000",
    6.59 -     "000000000000",
    6.60 -     "000200202000",
    6.61 -     "002020020200"),
    6.62 -    ("000022220000",
    6.63 -     "000222222000",
    6.64 -     "000222222000",
    6.65 -     "002222222200",
    6.66 -     "002222222200",
    6.67 -     "000333323000",
    6.68 -     "000303323000",
    6.69 -     "003333233000",
    6.70 -     "000333230000",
    6.71 -     "000033230000",
    6.72 -     "000200000000",
    6.73 -     "000222220220",
    6.74 -     "000222220220",
    6.75 -     "320220220220",
    6.76 -     "320220220220",
    6.77 -     "000000330000",
    6.78 -     "000222000000",
    6.79 -     "000222020000",
    6.80 -     "000222020000",
    6.81 -     "000222020000",
    6.82 -     "000222200000",
    6.83 -     "000000002200",
    6.84 -     "002222202200",
    6.85 -     "002222202200")
    6.86 -    ]
    6.87 +chars = [read_xpm("images/left1.xpm"),
    6.88 +         read_xpm("images/left2.xpm")]
    6.89  
    6.90  
    6.91  def read_sprite(lines):
     7.1 --- a/mapcode.oph	Mon Aug 08 23:14:12 2011 +0200
     7.2 +++ b/mapcode.oph	Tue Aug 09 01:40:46 2011 +0200
     7.3 @@ -446,7 +446,7 @@
     7.4  
     7.5  plot12x24_y0:           ; $70,$71=source address
     7.6                          ; $72,$73=destination address
     7.7 -    ldy #23
     7.8 +    ldy #15
     7.9  
    7.10      plotloop12x24_y0_0:
    7.11          lda ($70),y
    7.12 @@ -456,38 +456,38 @@
    7.13      clc
    7.14  
    7.15      lda $72
    7.16 -    adc #$28
    7.17 +    adc #$30
    7.18      sta $72
    7.19      lda $73
    7.20      adc #$01
    7.21 -    sta $73
    7.22 +    sta $73     ; 0x140 - 16
    7.23      clc
    7.24  
    7.25 -    ldy #47
    7.26 +    ldy #31
    7.27  
    7.28      plotloop12x24_y0_1:
    7.29          lda ($70),y
    7.30          sta ($72),y
    7.31          dey
    7.32 -        cpy #24
    7.33 +        cpy #16
    7.34          bpl plotloop12x24_y0_1
    7.35      clc
    7.36  
    7.37      lda $72
    7.38 -    adc #$28
    7.39 +    adc #$30
    7.40      sta $72
    7.41      lda $73
    7.42      adc #$01
    7.43 -    sta $73
    7.44 +    sta $73     ; 0x140 - 16
    7.45      clc
    7.46  
    7.47 -    ldy #71
    7.48 +    ldy #47
    7.49  
    7.50      plotloop12x24_y0_2:
    7.51          lda ($70),y
    7.52          sta ($72),y
    7.53          dey
    7.54 -        cpy #48
    7.55 +        cpy #32
    7.56          bpl plotloop12x24_y0_2
    7.57  
    7.58      rts