Jump to content
IGNORED

Pong with segments


karri

Recommended Posts

Here is a small example of splitting up pong to pieces. In cc65 you can create segments and store them on the cart. Then you just load in them on demand to save memory.

 

The new main.c looks like this:

 

#define MAIN_FILENR 0
#define PONG_FILENR 1
#define POPCORN_FILENR 2
#define INTRO_FILENR 3

void main()
{
 joy_install(&lynx_stdjoy);
 tgi_install(&lynx_160_102_16);
 tgi_init();
 tgi_setcollisiondetection(1);
 lynx_snd_init();
 CLI();
 while (1) {
   lynx_load(INTRO_FILENR);
   intro();

   lynx_snd_pause();
   lynx_load(POPCORN_FILENR);
   lynx_snd_play(0, musicptr.music0);
   lynx_snd_play(1, musicptr.music1);
   lynx_snd_play(2, musicptr.music2);
   lynx_snd_play(3, musicptr.music3);
   lynx_snd_continue();

   lynx_load(PONG_FILENR);
   play();
 }
}

 

In this case I split up the code into 4 pieces:

0 - main program and libraries

1 - pong

2 - popcorn music

3 - intro

 

In order to be able to load these I need to define a directory instead of the defdir. So I remove this line from the symbols in lynx-coll.cfg:

__DEFDIR__: type = import;

 

Instead I create a directory by hand:

 

; ------------------------------------------------------------------------
; Lynx directory
    .segment "DIRECTORY"

__DIRECTORY_START__:
off0=__STARTOFDIRECTORY__+(__DIRECTORY_END__-__DIRECTORY_START__)

; Entry 0 - first executable
block0=off0/__BLOCKSIZE__
len0=__STARTUP_SIZE__+__INIT_SIZE__+__CODE_SIZE__+__DATA_SIZE__+__RODATA_SIZE__
    .byte   <block0
    .word   off0 & (__BLOCKSIZE__ - 1)
    .byte   $88
    .word   __RAM_START__
    .word   len0
off1=off0+len0

; Entry 1 - pong
block1=off1/__BLOCKSIZE__
len1=__PONG_CODE_SIZE__+__PONG_DATA_SIZE__
    .byte   <block1
    .word   off1 & (__BLOCKSIZE__ - 1)
    .byte   $88
    .word   __PONG_CODE_LOAD__
    .word   len1
off2=off1+len1

; Entry 2 - popcorn
block2=off2/__BLOCKSIZE__
len2=__POPCORN_RODATA_SIZE__
    .byte   <block2
    .word   off2 & (__BLOCKSIZE__ - 1)
    .byte   $88
    .word   __POPCORN_RODATA_LOAD__
    .word   len2
off3=off2+len2

block3=off3/__BLOCKSIZE__
len3=__INTRO_CODE_SIZE__+__INTRO_RODATA_SIZE__
    .byte   <block3
    .word   off3 & (__BLOCKSIZE__ - 1)
    .byte   $88
    .word   __INTRO_CODE_LOAD__
    .word   len3
off4=off3+len3

__DIRECTORY_END__:

 

Here is the sources with makefile.

pong2.zip

  • Like 1
Link to comment
Share on other sites

Note, that I do not need the INTRO and PONG at the same time. So both get loaded at address $200. This re-using of precious RAM is a nice feature of the ld65 linker.

 

Name	   Start  End	Size   Align
-------------------------------------
INTRO_CODE 000200 0002C0 0000C1 00001
PONG_CODE  000200 000562 000363 00001
Edited by karri
  • Like 2
Link to comment
Share on other sites

Great stuff and good information for a tutorial episode. I am at the point with a new project now that I want to investigate the loading of files.

 

Here's a scenario: there's an engine that takes level data and enemy/npc information. The engine will need to access data from the levels and enemies, so it expects those at a fixed address, right? Any tips for loading/segmenting the level data from the engine?

 

In your example above, you get the INTRO and PONG segments to both load at $0200, because you created the SYMBOLS in lynx-coll.cfg yourself manually?

Link to comment
Share on other sites

The segmenting is really quite clever. If you have one segment with

char A;
void B() { }

 

and another segment with

 

void C() { }
int D;

 

You can use them like:

lynx_load(SEGMENT1);
A = 1;
B();
lynx_load(SEGMENT2);
D = 3;
C();

 

If these segments are defined to reside in the same spot in RAM you will lose the value of A when you load in the new SEGMENT2 on top of it.

 

You need to plan and type your segment definitions in the cfg-file and also in the Makefiles to compile the code into the correct segments.

--

Karri

  • Like 1
Link to comment
Share on other sites

Hmmm, I think this is beyond my capability =/ What I need to produce really is a simple way of replacing a bitmap of fixed size that's already in RAM with another from the ROM. I will keep looking at this example unless someone else knows a simpler way that I could swap images from ROM to RAM. This is a bit of a blow, I thought I was going to be able to churn a fair few Lynx games out but I cannot see a way around this =/ Part of the problem is the complexity of the linker stuff and makefiles - I know this is a simple example but its largely flown over my head. Times like this I realise that I am pretty average programmer only >.<

Link to comment
Share on other sites

I would start by reserving a fixed memory area where you can load a bitmap. In the cfg-file you add a new area like:

 

SYMBOLS {
 __BITMAPSTART__: type = weak, value = $0200;
 __BITMAPSIZE__: type = weak, value = $1000;
}
MEMORY {
 BITMAP1:   file = %O, define = yes, start = __BITMAPSTART__, size = __BITMAPSIZE__;
 BITMAP2:   file = %O, define = yes, start = __BITMAPSTART__, size = __BITMAPSIZE__;
 BITMAP3:   file = %O, define = yes, start = __BITMAPSTART__, size = __BITMAPSIZE__;
}
SEGMENTS {
 BITMAP1_RODATA:   load = BITMAP1,    type = ro,  define = yes;
 BITMAP2_RODATA:   load = BITMAP2,    type = ro,  define = yes;
 BITMAP3_RODATA:   load = BITMAP3,    type = ro,  define = yes;
}

 

Put the values in the SEGMENTS area as the last declaration. This alo means that the linker will put the bitmaps after the other code in the ROM.

 

Now you need to create a directory.s so you can find your bitmaps in the cart.

 

    .include "lynx.inc"
    .import		 __STARTOFDIRECTORY__
    .import		 __RAM_START__
    .import		 __CODE_SIZE__,__DATA_SIZE__,__RODATA_SIZE__
    .import		 __STARTUP_SIZE__,__INIT_SIZE__
    .import		 __BLOCKSIZE__
    .import		 __BITMAP1_RODATA_LOAD__
    .import		 __BITMAP1_RODATA_SIZE__
    .import		 __BITMAP2_RODATA_LOAD__
    .import		 __BITMAP2_RODATA_SIZE__
    .import		 __BITMAP3_RODATA_LOAD__
    .import		 __BITMAP3_RODATA_SIZE__

; Lynx directory
    .segment "DIRECTORY"

__DIRECTORY_START__:
off0=__STARTOFDIRECTORY__+(__DIRECTORY_END__-__DIRECTORY_START__)

; Entry 0 - first executable
block0=off0/__BLOCKSIZE__
len0=__STARTUP_SIZE__+__INIT_SIZE__+__CODE_SIZE__+__DATA_SIZE__+__RODATA_SIZE__
    .byte   <block0
    .word   off0 & (__BLOCKSIZE__ - 1)
    .byte   $88
    .word   __RAM_START__
    .word   len0
off1=off0+len0

; Entry 1 - bitmap1
block1=off1/__BLOCKSIZE__
len1=__BITMAP1_RODATA_SIZE__
    .byte   <block1
    .word   off1 & (__BLOCKSIZE__ - 1)
    .byte   $88
    .word   __BITMAP1_RODATA_LOAD__
    .word   len1
off2=off1+len1

; Entry 2 - bitmap2
block2=off2/__BLOCKSIZE__
len2=__BITMAP2_RODATA_SIZE__
    .byte   <block2
    .word   off2 & (__BLOCKSIZE__ - 1)
    .byte   $88
    .word   __BITMAP2_RODATA_LOAD__
    .word   len2
off3=off2+len2

; Entry 3 - bitmap3
block3=off3/__BLOCKSIZE__
len3=__BITMAP3_RODATA_SIZE__
    .byte   <block3
    .word   off3 & (__BLOCKSIZE__ - 1)
    .byte   $88
    .word   __BITMAP3_RODATA_LOAD__
    .word   len3
off4=off3+len3

 

You also have to remove the line that includes DEFDIR in the config file so your directory will replace the default mini-directory that contains just the first executable.

 

The next step is to define the segments for the bitmaps.

 

If your bitmaps are C-code you need to add a switch --rodata-name BITMAP1_RODATA to the bitmap1 source.

If they are asm-code you need to add

.segment "BITMAP1_RODATA"

to the start of the asm file.

 

Then you compile the bitmaps.

 

Later in your C-code you can get the bitmaps from cart and display them like:

 

 lynx_load(1);
 bitmap.data = bitmap1;
 tgi_sprite(&bitmap);
 lynx_load(2);
 bitmap.data = bitmap2;
 tgi_sprite(&bitmap);
 lynx_load(3);
 bitmap.data = bitmap3;
 tgi_sprite(&bitmap);

 

Hope this helps...

  • Like 2
Link to comment
Share on other sites

If your bitmaps are C-code you need to add a switch --rodata-name BITMAP1_RODATA to the bitmap1 source.

 

You can also use a #pragma in the .c file to change the RODATA segment for that file:

http://www.cc65.org/...65-7.html#ss7.8

 

PS:

 

Understanding segments and the linker config file is how you can build larger projects with cc65. Typically static data like a sprite or bitmap would be placed into the RODATA segment by default (since by how it's defined the compiler/linker figures it shouldn't be changing.) Using a pragma or .segment to change the segment is how you can place it where you want it (as defined by your linker config file). Karri's Pong example does this with code too (the INTRO and PONG segments.)

 

You have to remember that the C runtime will need to stay in RAM (unless you take extraordinary precautions not to call any library functions, and this means in interrupts as well.) This code is in the CODE segment, but there is also the STARTUP segment that you probably can jettison after main is called. On systems with memory mapped cartridges, the STARTUP segment can remain in the cart even-not so on the lynx unfortunately, due to it's design. In Karri's Pong example, you can see that he setup the CODE segment to go to $5000-so that's where the C runtime library will be, and any code that wasn't explicitly put into a different segment. He's also defined a bunch of other segments in between $200 and $5000, so needs to manage the code sizes for those segments as his project grows.

Edited by Shawn Jefferson
  • Like 2
Link to comment
Share on other sites

Hmmm, got a problem:-

 

 

1> ca65 -o game.o game.s

1> ca65 -t lynx -I "E:\CC65"\asminc -o directory.o directory.asm

1> cl65 -t lynx -o game.lnx lynx-160-102-16.o lynx-stdjoy.o level1bg.o target.o titlescreen.o soldier0.o soldier1.o soldier2.o mapscreen.o pixel.o levelselected.o bullethole.o tank0.o tank1.o tank2.o tank3.o life.o enemiesleft.o house1.o bullet.o enemybullet.o intro1.o intro2.o intro3.o intro4.o intro5.o intro6.o uzislightleft.o uzifarleft.o uzislightright.o uzifarright.o heli0.o heli1.o heli2.o heli3.o wall10.o wall11.o wall12.o wall13.o wall14.o wall15.o vblank.o game.o directory.o lynx.lib -m game.map

1>ld65.exe: Warning: [builtin config](13): Memory area overflow in `DIR', segment `DIRECTORY' (32 bytes)

1>ld65.exe: Error: Cannot generate output due to memory area overflow

1>NMAKE : fatal error U1077: 'E:\CC65\bin\cl65.EXE' : return code '0xff'

 

Not sure what's wrong here... I've used the example you posted Karri. I had to add __DIRECTORY_END__: to the end of directory.asm.

 

I've created level2bitmap.c as below, using Shawn suggestion of pragma, partly because I wasnt sure where to use the switches and pragma seemed easier at the time:-

 

#pragma rodataseg ("BITMAP1")

extern unsigned char level2bg[];

 

 

 

I don't think my makefiles have built the level2bg.bmp file yet, I need to tweak them to include it, which might be why the .map output shows BITMAP1 as very small in size. I am just not sure if the map is showing something missing, or whether it highlights anything else obviously wrong?

 

 

Segment list:

-------------

Name Start End Size Align

----------------------------------------------------

BITMAP1 000000 000026 000027 00001

DIRECTORY 000000 000027 000028 00001

EXEHDR 000000 00003F 000040 00001

ZEROPAGE 000000 000019 00001A 00001

EXTZP 00001A 000032 000019 00001

BOOTLDR 000200 0002CA 0000CB 00001

STARTUP 000200 00027C 00007D 00001

INIT 00027D 0002AB 00002F 00001

CODE 0002AC 005578 0052CD 00001

RODATA 005579 008FE9 003A71 00001

DATA 008FEA 009312 000329 00001

BSS 009313 009757 000445 00001

 

 

 

 

 

 

EDIT: That pragma should be BITMAP1_RODATA I think, but gives the same error. I think there's something wrong with directory.asm or something =/ God I wish I fully understood this. I've almost got a grasp of how this hangs together - but barely...

Edited by GadgetUK
Link to comment
Share on other sites

I am guessing my problem is going to be here:-

 

 

SYMBOLS {

__STACKSIZE__: type = weak, value = $0800; # 2k stack

__STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader

__BLOCKSIZE__: type = weak, value = 1024; # cart block size

__EXEHDR__: type = import;

__BOOTLDR__: type = import;

__BITMAPSTART__: type = weak, value = $0200;

__BITMAPSIZE__: type = weak, value = $1000;

 

}

MEMORY {

ZP: file = "", define = yes, start = $0000, size = $0100;

HEADER: file = %O, start = $0000, size = $0040;

BOOT: file = %O, start = $0200, size = __STARTOFDIRECTORY__;

DIR: file = %O, start = $0000, size = 4*8;

RAM: file = %O, define = yes, start = $0200, size = $9E58 - __STACKSIZE__;

BITMAP1: file = %O, define = yes, start = __BITMAPSTART__, size = __BITMAPSIZE__;

BITMAP2: file = %O, define = yes, start = __BITMAPSTART__, size = __BITMAPSIZE__;

BITMAP3: file = %O, define = yes, start = __BITMAPSTART__, size = __BITMAPSIZE__;

}

SEGMENTS {

EXEHDR: load = HEADER, type = ro;

BOOTLDR: load = BOOT, type = ro;

DIRECTORY:load = DIR, type = ro;

STARTUP: load = RAM, type = ro, define = yes;

LOWCODE: load = RAM, type = ro, optional = yes;

INIT: load = RAM, type = ro, define = yes, optional = yes;

CODE: load = RAM, type = ro, define = yes;

RODATA: load = RAM, type = ro, define = yes;

DATA: load = RAM, type = rw, define = yes;

BSS: load = RAM, type = bss, define = yes;

ZEROPAGE: load = ZP, type = zp;

EXTZP: load = ZP, type = zp, optional = yes;

APPZP: load = ZP, type = zp, optional = yes;

BITMAP1_RODATA: load = BITMAP1, type = ro, define = yes;

BITMAP2_RODATA: load = BITMAP2, type = ro, define = yes;

BITMAP3_RODATA: load = BITMAP3, type = ro, define = yes;

}

FEATURES {

CONDES: segment = INIT,

type = constructor,

label = __CONSTRUCTOR_TABLE__,

count = __CONSTRUCTOR_COUNT__;

CONDES: segment = RODATA,

type = destructor,

label = __DESTRUCTOR_TABLE__,

count = __DESTRUCTOR_COUNT__;

CONDES: segment = RODATA,

type = interruptor,

label = __INTERRUPTOR_TABLE__,

count = __INTERRUPTOR_COUNT__,

import = __CALLIRQ__;

}

 

 

EDIT: I think I am lost with this =/ I suspect now that I needed to change make files as well in order to make this work.

Edited by GadgetUK
Link to comment
Share on other sites

Thanks, tried that but still doesnt work =/ Tried increasing to more than 4,5,6,7,8 10, 20, 30, makes no difference to the error at all =/

 

EDIT: I wonder if its the directory.asm file. I reverted the .cfg file back as it was originally and still get the same error, which makes me wonder if something else is wrong with:-

 

.include "lynx.inc"

.import __STARTOFDIRECTORY__

.import __RAM_START__

.import __CODE_SIZE__,__DATA_SIZE__,__RODATA_SIZE__

.import __STARTUP_SIZE__,__INIT_SIZE__

.import __BLOCKSIZE__

.import __BITMAP1_RODATA_LOAD__

.import __BITMAP1_RODATA_SIZE__

.import __BITMAP2_RODATA_LOAD__

.import __BITMAP2_RODATA_SIZE__

.import __BITMAP3_RODATA_LOAD__

.import __BITMAP3_RODATA_SIZE__

 

; Lynx directory

.segment "DIRECTORY"

 

__DIRECTORY_START__:

off0=__STARTOFDIRECTORY__+(__DIRECTORY_END__-__DIRECTORY_START__)

 

; Entry 0 - first executable

block0=off0/__BLOCKSIZE__

len0=__STARTUP_SIZE__+__INIT_SIZE__+__CODE_SIZE__+__DATA_SIZE__+__RODATA_SIZE__

.byte <block0

.word off0 & (__BLOCKSIZE__ - 1)

.byte $88

.word __RAM_START__

.word len0

off1=off0+len0

 

; Entry 1 - bitmap1

block1=off1/__BLOCKSIZE__

len1=__BITMAP1_RODATA_SIZE__

.byte <block1

.word off1 & (__BLOCKSIZE__ - 1)

.byte $88

.word __BITMAP1_RODATA_LOAD__

.word len1

off2=off1+len1

 

; Entry 2 - bitmap2

block2=off2/__BLOCKSIZE__

len2=__BITMAP2_RODATA_SIZE__

.byte <block2

.word off2 & (__BLOCKSIZE__ - 1)

.byte $88

.word __BITMAP2_RODATA_LOAD__

.word len2

off3=off2+len2

 

; Entry 3 - bitmap3

block3=off3/__BLOCKSIZE__

len3=__BITMAP3_RODATA_SIZE__

.byte <block3

.word off3 & (__BLOCKSIZE__ - 1)

.byte $88

.word __BITMAP3_RODATA_LOAD__

.word len3

off4=off3+len3

__DIRECTORY_END__:

Edited by GadgetUK
Link to comment
Share on other sites

Check your error message. It clearly states if some area is too small. In this case you need to increase in manually in the cfg file.

 

The size of one directory entry is 8 bytes. In this case you need 32 bytes to hold four directory entries.

 

DIR: file = %O, start = $0000, size = 32;

  • Like 1
Link to comment
Share on other sites

EDIT: It wasnt referencing the .cfg file, so ive got past that now and come across this:-

 

1>Copyright © Microsoft Corporation. All rights reserved.

1> cl65 -t lynx -o game.lnx lynx-160-102-16.o lynx-stdjoy.o directory.o level1bg.o target.o titlescreen.o soldier0.o soldier1.o soldier2.o mapscreen.o pixel.o levelselected.o bullethole.o tank0.o tank1.o tank2.o tank3.o life.o enemiesleft.o house1.o bullet.o enemybullet.o intro1.o intro2.o intro3.o intro4.o intro5.o intro6.o uzislightleft.o uzifarleft.o uzislightright.o uzifarright.o heli0.o heli1.o heli2.o heli3.o wall10.o wall11.o wall12.o wall13.o wall14.o wall15.o vblank.o game.o -C lynx-coll.cfg lynx.lib -m game.map

1>ld65.exe: Warning: lynx-coll.cfg(54): Segment `BITMAP1_RODATA' does not exist

1>ld65.exe: Warning: lynx-coll.cfg(54): Segment `BITMAP2_RODATA' does not exist

1>ld65.exe: Warning: lynx-coll.cfg(54): Segment `BITMAP3_RODATA' does not exist

1>Unresolved external `__BITMAP1_RODATA_LOAD__' referenced in:

1> directory.asm(36)

1>Unresolved external `__BITMAP1_RODATA_SIZE__' referenced in:

1> directory.asm(32)

1>Unresolved external `__BITMAP2_RODATA_LOAD__' referenced in:

1> directory.asm(46)

1>Unresolved external `__BITMAP2_RODATA_SIZE__' referenced in:

1> directory.asm(42)

1>Unresolved external `__BITMAP3_RODATA_LOAD__' referenced in:

1> directory.asm(56)

1>Unresolved external `__BITMAP3_RODATA_SIZE__' referenced in:

1> directory.asm(52)

1>ld65.exe: Error: 6 unresolved external(s) found - cannot create output file

1>NMAKE : fatal error U1077: 'E:\CC65\bin\cl65.EXE' : return code '0xff'

1>Stop.

1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"

1>Build log was saved at "file://d:\Lynx\Starter\Starter\Debug\BuildLog.htm"

1>Starter - 2 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Edited by GadgetUK
Link to comment
Share on other sites

Thanks, I think I am almost there now, but not quite. It seems to be putting the bitmaps in the RODATA segment still - see memory map below. BITMAP3_RODATA seems to only contain 32 bytes or something, and there's no sign of BITMAP2_RODATA or BITMAP1_RODATA but that could be because the compile failed. It seems to be trying to put everything in the RODATA segment still imo.

 

 

1> cl65 -t lynx -o game.lnx lynx-160-102-16.o lynx-stdjoy.o directory.o level1bg.o level2bg.o level3bg.o target.o titlescreen.o soldier0.o soldier1.o soldier2.o mapscreen.o pixel.o levelselected.o bullethole.o tank0.o tank1.o tank2.o tank3.o life.o enemiesleft.o house1.o bullet.o enemybullet.o intro1.o intro2.o intro3.o intro4.o intro5.o intro6.o uzislightleft.o uzifarleft.o uzislightright.o uzifarright.o heli0.o heli1.o heli2.o heli3.o wall10.o wall11.o wall12.o wall13.o wall14.o wall15.o vblank.o game.o -C lynx-coll.cfg lynx.lib -m game.map

1>ld65.exe: Warning: lynx-coll.cfg(16): Memory area overflow in `RAM', segment `RODATA' (1849 bytes)

1>ld65.exe: Error: Cannot generate output due to memory area overflow

 

 

 

 

Modules list:

-------------

lynx-160-102-16.o:

CODE Offs=000000 Size=0006E4 Align=00001 Fill=0000

BSS Offs=000000 Size=0000BD Align=00001 Fill=0000

DATA Offs=000000 Size=000059 Align=00001 Fill=0000

lynx-stdjoy.o:

CODE Offs=0006E4 Size=000028 Align=00001 Fill=0000

directory.o:

DIRECTORY Offs=000000 Size=000020 Align=00001 Fill=0000

level1bg.o:

RODATA Offs=000000 Size=0007AA Align=00001 Fill=0000

level2bg.o:

RODATA Offs=0007AA Size=000852 Align=00001 Fill=0000

level3bg.o:

RODATA Offs=000FFC Size=000755 Align=00001 Fill=0000

target.o:

RODATA Offs=001751 Size=00004B Align=00001 Fill=0000

titlescreen.o:

RODATA Offs=00179C Size=000B85 Align=00001 Fill=0000

soldier0.o:

RODATA Offs=002321 Size=0000E2 Align=00001 Fill=0000

soldier1.o:

RODATA Offs=002403 Size=0000CE Align=00001 Fill=0000

soldier2.o:

RODATA Offs=0024D1 Size=0000F2 Align=00001 Fill=0000

mapscreen.o:

RODATA Offs=0025C3 Size=00076D Align=00001 Fill=0000

pixel.o:

RODATA Offs=002D30 Size=000007 Align=00001 Fill=0000

levelselected.o:

RODATA Offs=002D37 Size=0000D9 Align=00001 Fill=0000

bullethole.o:

RODATA Offs=002E10 Size=000034 Align=00001 Fill=0000

tank0.o:

RODATA Offs=002E44 Size=00008C Align=00001 Fill=0000

tank1.o:

RODATA Offs=002ED0 Size=00008C Align=00001 Fill=0000

tank2.o:

RODATA Offs=002F5C Size=00008D Align=00001 Fill=0000

tank3.o:

RODATA Offs=002FE9 Size=00008D Align=00001 Fill=0000

life.o:

RODATA Offs=003076 Size=00002A Align=00001 Fill=0000

enemiesleft.o:

RODATA Offs=0030A0 Size=000030 Align=00001 Fill=0000

house1.o:

RODATA Offs=0030D0 Size=0001C6 Align=00001 Fill=0000

bullet.o:

RODATA Offs=003296 Size=000013 Align=00001 Fill=0000

enemybullet.o:

RODATA Offs=0032A9 Size=000029 Align=00001 Fill=0000

intro1.o:

RODATA Offs=0032D2 Size=000251 Align=00001 Fill=0000

intro2.o:

RODATA Offs=003523 Size=000257 Align=00001 Fill=0000

intro3.o:

RODATA Offs=00377A Size=000259 Align=00001 Fill=0000

intro4.o:

RODATA Offs=0039D3 Size=00020D Align=00001 Fill=0000

intro5.o:

RODATA Offs=003BE0 Size=000211 Align=00001 Fill=0000

intro6.o:

RODATA Offs=003DF1 Size=000231 Align=00001 Fill=0000

uzislightleft.o:

RODATA Offs=004022 Size=0000D4 Align=00001 Fill=0000

uzifarleft.o:

RODATA Offs=0040F6 Size=0000FD Align=00001 Fill=0000

uzislightright.o:

RODATA Offs=0041F3 Size=0000D2 Align=00001 Fill=0000

uzifarright.o:

RODATA Offs=0042C5 Size=0000FF Align=00001 Fill=0000

heli0.o:

RODATA Offs=0043C4 Size=000092 Align=00001 Fill=0000

heli1.o:

RODATA Offs=004456 Size=000093 Align=00001 Fill=0000

heli2.o:

RODATA Offs=0044E9 Size=00007B Align=00001 Fill=0000

heli3.o:

RODATA Offs=004564 Size=00007B Align=00001 Fill=0000

wall10.o:

RODATA Offs=0045DF Size=000091 Align=00001 Fill=0000

wall11.o:

RODATA Offs=004670 Size=000099 Align=00001 Fill=0000

wall12.o:

RODATA Offs=004709 Size=0000AD Align=00001 Fill=0000

wall13.o:

RODATA Offs=0047B6 Size=0000B7 Align=00001 Fill=0000

wall14.o:

RODATA Offs=00486D Size=0000AA Align=00001 Fill=0000

wall15.o:

RODATA Offs=004917 Size=0000A4 Align=00001 Fill=0000

vblank.o:

CODE Offs=00070C Size=000024 Align=00001 Fill=0000

game.o:

CODE Offs=000730 Size=003E1A Align=00001 Fill=0000

BSS Offs=0000BD Size=00033A Align=00001 Fill=0000

DATA Offs=000059 Size=000238 Align=00001 Fill=0000

BITMAP3_RODATA Offs=000000 Size=000027 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(add.o):

CODE Offs=00454A Size=000019 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(addysp.o):

CODE Offs=004563 Size=00000E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(aslax1.o):

CODE Offs=004571 Size=000008 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(aslax3.o):

CODE Offs=004579 Size=00000E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(aslax4.o):

CODE Offs=004587 Size=000011 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(axlong.o):

CODE Offs=004598 Size=000012 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(bneg.o):

CODE Offs=0045AA Size=00000E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(callirq.o):

DATA Offs=000291 Size=00001E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(callmain.o):

CODE Offs=0045B8 Size=000017 Align=00001 Fill=0000

BSS Offs=0003F7 Size=000004 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(condes.o):

CODE Offs=0045CF Size=00000C Align=00001 Fill=0000

DATA Offs=0002AF Size=000025 Align=00001 Fill=0000

INIT Offs=000000 Size=00000C Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(decax1.o):

CODE Offs=0045DB Size=000007 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(decax2.o):

CODE Offs=0045E2 Size=000007 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(decax8.o):

CODE Offs=0045E9 Size=000007 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(decaxy.o):

CODE Offs=0045F0 Size=000009 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(decsp4.o):

CODE Offs=0045F9 Size=00000D Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(div.o):

CODE Offs=004606 Size=000018 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(icmp.o):

CODE Offs=00461E Size=00002E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(imul16x16r32.o):

CODE Offs=00464C Size=00002B Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(incax2.o):

CODE Offs=004677 Size=000007 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(incax7.o):

CODE Offs=00467E Size=000005 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(incax8.o):

CODE Offs=004683 Size=000005 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(incaxy.o):

CODE Offs=004688 Size=00000B Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(incsp1.o):

CODE Offs=004693 Size=000007 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(incsp2.o):

CODE Offs=00469A Size=000015 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(incsp4.o):

CODE Offs=0046AF Size=000005 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(ladd.o):

CODE Offs=0046B4 Size=000024 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(laddeq.o):

CODE Offs=0046D8 Size=00002D Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(lcmp.o):

CODE Offs=004705 Size=00003B Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(ldaxi.o):

CODE Offs=004740 Size=00000D Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(ldeaxi.o):

CODE Offs=00474D Size=000017 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(ldec.o):

CODE Offs=004764 Size=00001A Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(leq.o):

CODE Offs=00477E Size=000006 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(linc.o):

CODE Offs=004784 Size=000011 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(lne.o):

CODE Offs=004795 Size=000006 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(lneg.o):

CODE Offs=00479B Size=00001E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(lpush.o):

CODE Offs=0047B9 Size=000021 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(lsave.o):

CODE Offs=0047DA Size=00001C Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(luge.o):

CODE Offs=0047F6 Size=000006 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(lugt.o):

CODE Offs=0047FC Size=000006 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(makebool.o):

CODE Offs=004802 Size=000031 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(mod.o):

CODE Offs=004833 Size=000014 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(mul.o):

CODE Offs=004847 Size=000045 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(mul8.o):

CODE Offs=00488C Size=00003A Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(neg.o):

CODE Offs=0048C6 Size=00000E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(popa.o):

CODE Offs=0048D4 Size=00000A Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(popsreg.o):

CODE Offs=0048DE Size=00000F Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(pusha.o):

CODE Offs=0048ED Size=000016 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(pushax.o):

CODE Offs=004903 Size=00001A Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(pushw.o):

CODE Offs=00491D Size=00000F Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(return1.o):

CODE Offs=00492C Size=000005 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(shelp.o):

CODE Offs=004931 Size=00001E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(shrax4.o):

CODE Offs=00494F Size=000011 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(staspidx.o):

CODE Offs=004960 Size=000016 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(staxspi.o):

CODE Offs=004976 Size=00001B Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(steaxspi.o):

CODE Offs=004991 Size=000026 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(sub.o):

CODE Offs=0049B7 Size=000014 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(udiv.o):

CODE Offs=0049CB Size=00004F Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(udiv32by16r16.o):

CODE Offs=004A1A Size=000031 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(umul16x16r32.o):

CODE Offs=004A4B Size=00002C Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(umul8x16r24.o):

CODE Offs=004A77 Size=00002E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(zeropage.o):

ZEROPAGE Offs=000000 Size=00001A Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(bootldr.o):

BOOTLDR Offs=000000 Size=0000CB Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(crt0.o):

CODE Offs=004AA5 Size=000011 Align=00001 Fill=0000

RODATA Offs=0049BB Size=00002C Align=00001 Fill=0000

STARTUP Offs=000000 Size=00007D Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(exehdr.o):

EXEHDR Offs=000000 Size=000040 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(extzp.o):

EXTZP Offs=000000 Size=000019 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(kbhit.o):

CODE Offs=004AB6 Size=000038 Align=00001 Fill=0000

DATA Offs=0002D4 Size=000006 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_colors.o):

E:\CC65\lib/lynx.lib(toascii.o):

CODE Offs=004AEE Size=000003 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(_hextab.o):

RODATA Offs=0049E7 Size=000010 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(_longminstr.o):

RODATA Offs=0049F7 Size=00000C Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(itoa.o):

CODE Offs=004AF1 Size=000094 Align=00001 Fill=0000

RODATA Offs=004A03 Size=000007 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(ltoa.o):

CODE Offs=004B85 Size=0000AF Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(memcpy.o):

CODE Offs=004C34 Size=000041 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(rand.o):

CODE Offs=004C75 Size=00004C Align=00001 Fill=0000

DATA Offs=0002DA Size=000004 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(strlen.o):

CODE Offs=004CC1 Size=000016 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(zerobss.o):

INIT Offs=00000C Size=000023 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(joy-kernel.o):

CODE Offs=004CD7 Size=000062 Align=00001 Fill=0000

RODATA Offs=004A0A Size=000004 Align=00001 Fill=0000

BSS Offs=0003FB Size=00000A Align=00001 Fill=0000

DATA Offs=0002DE Size=00000F Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(joy_read.o):

E:\CC65\lib/lynx.lib(tgi-kernel.o):

CODE Offs=004D39 Size=000083 Align=00001 Fill=0000

RODATA Offs=004A0E Size=000004 Align=00001 Fill=0000

BSS Offs=000405 Size=000028 Align=00001 Fill=0000

DATA Offs=0002ED Size=00003C Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_clear.o):

E:\CC65\lib/lynx.lib(tgi_clippedline.o):

CODE Offs=004DBC Size=0001E3 Align=00001 Fill=0000

BSS Offs=00042D Size=000008 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_curtoxy.o):

CODE Offs=004F9F Size=000015 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_done.o):

CODE Offs=004FB4 Size=00000E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_gettextwidth.o):

CODE Offs=004FC2 Size=000057 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_getxres.o):

CODE Offs=005019 Size=000007 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_getyres.o):

CODE Offs=005020 Size=000007 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_imulround.o):

CODE Offs=005027 Size=000025 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_init.o):

CODE Offs=00504C Size=000058 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_ioctl.o):

CODE Offs=0050A4 Size=00000A Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_outcode.o):

CODE Offs=0050AE Size=000041 Align=00001 Fill=0000

BSS Offs=000435 Size=000008 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_outtext.o):

CODE Offs=0050EF Size=000091 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_outtextxy.o):

CODE Offs=005180 Size=000021 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_setcolor.o):

CODE Offs=0051A1 Size=00000E Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_setpalette.o):

CODE Offs=0051AF Size=000007 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_settextstyle.o):

CODE Offs=0051B6 Size=000042 Align=00001 Fill=0000

E:\CC65\lib/lynx.lib(tgi_vectorchar.o):

CODE Offs=0051F8 Size=0000D5 Align=00001 Fill=0000

BSS Offs=00043D Size=000008 Align=00001 Fill=0000

 

Segment list:

-------------

Name Start End Size Align

----------------------------------------------------

DIRECTORY 000000 00001F 000020 00001

EXEHDR 000000 00003F 000040 00001

STARTUP 000000 00007C 00007D 00001

ZEROPAGE 000000 000019 00001A 00001

EXTZP 00001A 000032 000019 00001

INIT 00007D 0000AB 00002F 00001

CODE 0000AC 005378 0052CD 00001

BITMAP3_RODATA 000200 000226 000027 00001

BOOTLDR 000200 0002CA 0000CB 00001

RODATA 005379 009D90 004A18 00001

DATA 009D91 00A0B9 000329 00001

BSS 00A0BA 00A4FE 000445 00001

 

 

I am not sure I am doing everything right here, just to clarify:-

 

1) Modified the lynx-coll.cfg as done by Karri.

2) Created 3 new .c files which look like this, and this is where I think I could be going wrong as its contains the external link there to the actual bitmap.

 

#pragma rodata-name ("BITMAP1_RODATA")

extern unsigned char level1bg[];

 

3) In my main.c ive #included the 3 new .c files, or it complains there's nothing for the 3 segments are per my last post above which Karri last replied on. I am wondering if its including the 3 .c files in the new segments but still trying to put the bitmap.o files into the RODATA segment, is that what's going on here?

 

 

And for reference, here's my make files, which I am still not sure if need changing to accommodate the new segments:-

 

lynxcc65.mak:-

 

CC65="E:\CC65"

CC65_BIN=$(CC65)\bin

CC65_INC=$(CC65)\include

CC65_ASMINC=$(CC65)\asminc

CC65_TOOLS=$(CC65)\wbin

 

BUILDDIR=$(MAKEDIR)\$(BUILD)

ODIR=$(MAKEDIR)\obj

 

.SUFFIXES : .c .s .o .asm .bmp .pal .spr

.SOURCE :

# Compiling for Atari Lynx system

SYS=lynx

 

# Names of tools

CO=co65

CC=cc65

AS=ca65

AR=ar65

CL=cl65

SPRPCK=E:\CC65\sprpck\sprpck

CP=copy

RM=rm

ECHO=echo

TOUCH=touch

 

CODE_SEGMENT=CODE

DATA_SEGMENT=DATA

RODATA_SEGMENT=RODATA

BSS_SEGMENT=BSS

BITMAP1_RODATA_SEGMENT=BITMAP1_RODATA

BITMAP2_RODATA_SEGMENT=BITMAP2_RODATA

BITMAP3_RODATA_SEGMENT=BITMAP3_RODATA

 

SEGMENTS=--code-name $(CODE_SEGMENT) \

--rodata-name $(RODATA_SEGMENT) \

--bss-name $(BSS_SEGMENT) \

--data-name $(DATA_SEGMENT)

 

# Flag for assembler

AFLAGS=

 

# Flags for C-code compiler

CFLAGS=-I . -t $(SYS) --add-source -O -Or -Cl -Os

 

# Rule for making a *.o file out of a *.s file

.s.o:

$(AS) -t $(SYS) -I $(CC65_ASMINC) -o $@ $(AFLAGS) $<

.asm.o:

$(AS) -t $(SYS) -I $(CC65_ASMINC) -o $@ $(AFLAGS) $<

 

# Rule for making a *.o file out of a *.c file

.c.o:

$(CC) $(SEGMENTS) $(CFLAGS) $<

$(AS) -o $@ $(AFLAGS) $(*).s

 

lynx-stdjoy.o:

$(CP) $(CC65_INC)\..\joy\$*.joy .

$(CO) --code-label _lynxjoy $*.joy

$(AS) -t lynx -o $@ $(AFLAGS) $*.s

$(RM) $*.joy

$(RM) $*.s

 

lynx-160-102-16.o:

$(CP) $(CC65_INC)\..\tgi\$*.tgi .

$(CO) --code-label _lynxtgi $*.tgi

$(AS) -t lynx -o $@ $(AFLAGS) $*.s

$(RM) $*.tgi

$(RM) $*.s

 

# Rule for making a *.o file out of a *.bmp file

.bmp.o:

$(SPRPCK) -t6 -p2 $<

$(ECHO) .global _$(*B) > $*.s

$(ECHO) .segment "$(RODATA_SEGMENT)" >> $*.s

$(ECHO) _$(*B): .incbin "$*.spr" >> $*.s

$(AS) -t lynx -o $@ $(AFLAGS) $*.s

$(RM) $*.s

# $(RM) $*.pal

# $(RM) $*.spr

 

 

 

 

 

game.mak:-

 

!INCLUDE <lynxcc65.mak>

 

target = game.lnx

objects = lynx-160-102-16.o lynx-stdjoy.o directory.o level1bg.o level2bg.o level3bg.o target.o titlescreen.o soldier0.o soldier1.o soldier2.o mapscreen.o pixel.o levelselected.o bullethole.o tank0.o tank1.o tank2.o tank3.o life.o enemiesleft.o house1.o bullet.o enemybullet.o intro1.o intro2.o intro3.o intro4.o intro5.o intro6.o uzislightleft.o uzifarleft.o uzislightright.o uzifarright.o heli0.o heli1.o heli2.o heli3.o wall10.o wall11.o wall12.o wall13.o wall14.o wall15.o vblank.o game.o

 

$(target) : $(objects)

$(CL) -t $(SYS) -o $@ $(objects) -C lynx-coll.cfg lynx.lib -m game.map

$(CP) $@ .\$(BUILD)\$@

 

all: $(target)

 

clean:

$(RM) -f *.tgi

$(RM) -f *.s

$(RM) -f *.joy

$(RM) -f *.o

$(RM) -f *.lnx

$(RM) -f *.pal

$(RM) -f *.spr

Edited by GadgetUK
Link to comment
Share on other sites

Well you are putting the pragma in the wrong file.

 

If you are using sprpck to create some bitmap.spr file then you need to write something like:

 

bitmap1.s:

 

.global _bitmap1

.segment "BITMAP1_RODATA"

_bitmap1: .include "bitmap.spr"

 

and compile that one.

  • Like 1
Link to comment
Share on other sites

You can also create a custom rule in the Makefile

 

Put this at the end

 

bitmap1.o: bitmap1.bmp

$(SPRPCK) -t6 -p2 $<

$(ECHO) .global _$(*B) > $*.s

$(ECHO) .segment "BITMAP1_RODATA" >> $*.s

$(ECHO) _$(*B): .incbin "$*.spr" >> $*.s

$(AS) -t lynx -o $@ $(AFLAGS) $*.s

$(RM) $*.s

  • Like 1
Link to comment
Share on other sites

Thanks again!! Made some more positive progress thanks to your help, it's much appreciated.

 

This is my memory map now:- (with it running but not switching images). I had to change the start of RAM in the cfg file to $1200 from 0 or it just crashed, does that sound right? I've put the cfg file as is now below. I can see that maybe the loader can be overwritten later etc but my understanding is that if the RAM starts at 0 then the bitmaps at 200 will start to overwrite the code and data?

 

DIRECTORY 000000 00001F 000020 00001

EXEHDR 000000 00003F 000040 00001

ZEROPAGE 000000 000019 00001A 00001

EXTZP 00001A 000032 000019 00001

BITMAP1_RODATA 000200 0009A9 0007AA 00001

BITMAP2_RODATA 000200 000A51 000852 00001

BITMAP3_RODATA 000200 000954 000755 00001

BOOTLDR 000200 0002CA 0000CB 00001

STARTUP 001200 00127C 00007D 00001

INIT 00127D 0012AB 00002F 00001

CODE 0012AC 00656A 0052BF 00001

RODATA 00656B 009858 0032EE 00001

DATA 009859 009B81 000329 00001

BSS 009B82 009FC6 000445 00001

 

So now it compiles, and I can see the 3 bitmaps each in their own segment - which is great, but when I have the following line of code in my main.c (anywhere in the code, not even in a runable part):-

 

lynx_load(1);

 

This causes the game to start up but freeze on the title screen - the code is not even called at that point, so purely including it has effected the compile in someway. I am also unsure how to reference the bitmaps in the new segments. In your example above you said:-

 

bitmap.data = bitmap1; //to swap to bitmap 1 etc

 

The problem i've got at the moment (besides it not running at all with that lynx_load line above, is that I dont have a symbol called bitmap1, and I am not sure how to declare it, is it just

 

extern char bitmap1[]; ?

 

 

Really sorry for these questions that must be annoying as hell!!

 

 

 

 

 

cfg file for reference:-

 

 

SYMBOLS {

__STACKSIZE__: type = weak, value = $0800; # 2k stack

__STARTOFDIRECTORY__: type = weak, value = $00CB; # start just after loader

__BLOCKSIZE__: type = weak, value = 1024; # cart block size

__EXEHDR__: type = import;

__BOOTLDR__: type = import;

__BITMAPSTART__: type = weak, value = $0200;

__BITMAPSIZE__: type = weak, value = $1000;

 

}

MEMORY {

ZP: file = "", define = yes, start = $0000, size = $0100;

HEADER: file = %O, start = $0000, size = $0040;

BOOT: file = %O, start = $0200, size = __STARTOFDIRECTORY__;

DIR: file = %O, start = $0000, size = 32;

RAM: file = %O, define = yes, start = $1200, size = $9E58 - __STACKSIZE__;

BITMAP1: file = %O, define = yes, start = __BITMAPSTART__, size = __BITMAPSIZE__;

BITMAP2: file = %O, define = yes, start = __BITMAPSTART__, size = __BITMAPSIZE__;

BITMAP3: file = %O, define = yes, start = __BITMAPSTART__, size = __BITMAPSIZE__;

}

SEGMENTS {

EXEHDR: load = HEADER, type = ro;

BOOTLDR: load = BOOT, type = ro;

DIRECTORY:load = DIR, type = ro;

STARTUP: load = RAM, type = ro, define = yes;

LOWCODE: load = RAM, type = ro, optional = yes;

INIT: load = RAM, type = ro, define = yes, optional = yes;

CODE: load = RAM, type = ro, define = yes;

RODATA: load = RAM, type = ro, define = yes;

DATA: load = RAM, type = rw, define = yes;

BSS: load = RAM, type = bss, define = yes;

ZEROPAGE: load = ZP, type = zp;

EXTZP: load = ZP, type = zp, optional = yes;

APPZP: load = ZP, type = zp, optional = yes;

BITMAP1_RODATA: load = BITMAP1, type = ro, define = yes;

BITMAP2_RODATA: load = BITMAP2, type = ro, define = yes;

BITMAP3_RODATA: load = BITMAP3, type = ro, define = yes;

}

FEATURES {

CONDES: segment = INIT,

type = constructor,

label = __CONSTRUCTOR_TABLE__,

count = __CONSTRUCTOR_COUNT__;

CONDES: segment = RODATA,

type = destructor,

label = __DESTRUCTOR_TABLE__,

count = __DESTRUCTOR_COUNT__;

CONDES: segment = RODATA,

type = interruptor,

label = __INTERRUPTOR_TABLE__,

count = __INTERRUPTOR_COUNT__,

import = __CALLIRQ__;

}

Edited by GadgetUK
Link to comment
Share on other sites

All sorted!!! Thank you very very much, there's no way I could have done this without your help and the large amount of time you've spent helping me on this one.

 

It was simply a case of little mistakes here and there on my part. For anyone else trying to work out how to reference the bitmaps, you do it the same way as normal. eg. bitmap1.bmp (and ultimately bitmap1.o), you normally just have extern char bitmap1[]; and that's exactly the same even though the .o file isn't firmly linked to the executable part of the directory. I think that directory 0 = the executable btw?

 

The other question I have is back on the subject of creating bitmaps as a .s (or in my case .asm) file. I tried your example a few posts back and it wouldnt compile, it kept going on about unexpected characters, which were actually the hex values from the .spr file it was complaining about. Just curious because I would like to get it working with .asm files rather than the additional make file rules I am using at the moment.

 

Thanks!!!!

 

 

EDIT: And the reason why the lynx_load was causing it to hang was memory again - I was still using too much of the RODATA segment with images. I've taken all the images out and expanded the directory to 2 more images to accommodate and that solved the hanging on start up with lynx_load in the code.

 

I would also like to clarify my question about the RAM start address, originally 0 I changed it to 1200 to accommodate the 1000 size bitmaps starting at 200, is that right or am I missing something? Would be useful to understand typical memory map - how much RAM for code and data typically, with collision buffers used and where are the 2 / 3 screen sized buffers located - is that handled by the compiler or is it a fixed address?

Edited by GadgetUK
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...