Jump to content
IGNORED

Learning Lynx coding by hacking PegSolitaire


Turbo Laser Lynx

Recommended Posts

PegSolitaire seems like a really nice entry point for starting tinkering some small Lynx games together. It's small and really easy to grasp. But unfortunately I ran into problems fast, any help appreciated :P

 

First I thought I got it to compile on my raspberry pi, but when I deleted all .o files I noticed .bmp files wouldn't compile. That's obviously because sprpck has been replaced by sp65 in the toolchain. But I couldn't find a linux version of sprpck, the one on bitbucket seems to compile to an exe file.

 

Secondly I was thinking of replacing the .bmp files with .pcx files and altering the makefile. I tried a lot of different stuff but couldn't get it right without causing different errors. Could someone help me with the correct approach?

 

in the intro makefile of PegSolitaire every image is hadled by themselves:

SPRPCK=../sprpck

bg.o : bg.bmp
	$(SPRPCK) -t6 -p2 -a000000 $< 
	$(ECHO) .global _bg > $*.s
	$(ECHO) .segment \"$(RODATA_SEGMENT)\" >> $*.s
	$(ECHO) _bg: .incbin \"bg.spr\" >> $*.s
	$(AS) -t lynx -o $@ $(AFLAGS) $*.s
	$(RM) $*.pal
	$(RM) $*.s
	$(RM) $*.spr

in the intro makefile of shaken the recipe for handling pcx is more generic and can handle all pcx files and uses an object list, but I was not able to combine the two in a sensible manner.

SP=sp65

# Rule for making a *.o file out of a *.bmp file
%.o : %.pcx
    $(SP) -r $< -c lynx-sprite,mode=packed -w $*.c,ident=$*
    $(CC) $(CFLAGS) $(SEGMENTS) -o $*.s $*.c
    $(AS) -o $@ $(AFLAGS) $(*).s
    $(RM) $*.s

PegSolitaireV1_3.zip

Edited by Turbo Laser Lynx
Link to comment
Share on other sites

I read in my bmp files in Gimp and export them as pcx. I also changed the Makefiles and some init stuff so that it compiles nicely. Unfortunately I could not get it to work yet. This should also compile on Raspberry Pi now. It uses pcx and sp65. You must copy the sp65 file from lynx/tools/cc65/src/sp65/sp65 to /usr/local/bin manually. There is some bug in the installation script.

PegSolitaireV1.4.zip

Link to comment
Share on other sites

Hey thanks man! That's so nice of you! I have such an itch getting to create something for the Lynx that I already started something small on the oldest version of newcc65 because that was the only one I could manage to get up and running :grin: It would obviously make better sense getting stuff up and running with cc65 with the cart template(s) and all the improvements, so thank you very much!

 

I tried the original cart in the zip file and it only switches between green stripes and a black screen. I've copied the sp65 file and the whole thing compiles nicely on my pi, also when I clean away o files and stuff, but the resulting cart still only shows the green stripes, hmm..

Edited by Turbo Laser Lynx
Link to comment
Share on other sites

Thanks again! Yeah, something seems to be wrong when trying to convert pcx images.

 

Btw, what would have been the best way to debug that memory bug I wonder? I mean would I have had to manually calculate the memory stuff in lynxcart.cfg or would it have been more easy to spot in the cart.map or are there perhaps some tools in dev-handy (which unfortunately always crashes for me when I've tried it, and I don't know how to use it anyway (yet at least)).

Link to comment
Share on other sites

The cart starts with the bootloader followed by the directory. The size of the bootloader changed when we found out how the encryption worked.

 

In the map file you see the size of the bootloader.

 

BOOTLDR 000200 0002CA 0000CB 00001

 

It will be the same for all games using this version of cc65. It is defined in lynx/tools/cc65/libsrc/lynx/bootldr.s. This size will never change.

 

So you need to tell the Lynx where the directory starts. And that is exactly CB bytes from the start of the cart.

 

There are other things that are pretty fixed as well.

__BOOTLDR__: type = import;

 

This line tells that you want to create a cart. It signals the linker to include the bootloader in the build.

 

And finally

__BLOCKSIZE__: type = weak, value = 2048;

 

this chooses a 512k ROM chip. The other possible values are 1024 for a 256k chip and 512 for a 128k chip.

 

I still don't know what else went wrong in converting PegSolitaire. But debugging it is nicer than cleaning up my house (which I should do today) so let's see what I find.

 

Edit: In the directory you should no longer do the ^ $ffff stuff. I managed to save a few bytes and keeping the file system closer to standard by declaring the block number and file lengths as they are. I still have small glitches in the graphics. A few pixels that flush at the intro screen.

 

Edit2: There is a bug in the sp65 sprite packer. In the background the text PegSolitaire gets compressed wrong. So I had to change the sprite type to literal to make it work.

 

A working cc65 version is included. Enjoy :)

 

PegSolitaireV1.4.zip

Edited by karri
Link to comment
Share on other sites

There was no bug in sp65 packed mode. The title had only 3 colours so sp65 created a sprite with only 2 bits per pixel. The cure was to define the sprites correctly in c-code (BPP_2).

static SCB_REHV_PAL bgSprite = {
        BPP_4 | TYPE_NORMAL,
        PACKED | REHV,
        NO_COLLIDE,
        0,
        bg,
        0, 0,
        0x100, 0x100,
        {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF}
};

static SCB_REHV_PAL titleSprite = {
        BPP_2 | TYPE_NORMAL,
        PACKED | REHV,
        NO_COLLIDE,
        0,
        title,
        0, 0,
        0x100, 0x100,
        {0x01,0x23}
};

Attached the fixed, fixed version :) (The cursor is running very fast. There may still be some bug around. But time to continue vacuuming :( )

PegSolitaireV1.4.zip

Edited by karri
  • Like 1
Link to comment
Share on other sites

If I make the intro segment size bigger in lynxcart.cfg (in pegsolitaire)

 

from

__BANK1SIZE__: type = weak, value = $3A40;
__BANK7SIZE__: type = weak, value = $5A40;

to

__BANK1SIZE__: type = weak, value = $5A40;
__BANK7SIZE__: type = weak, value = $5A40;

this just means I expanded the space for the intro on the cart to be as big as the space for the game right? At least it compiles with that change.

 

I guess this would only make sense if you would want to have a really elaborate intro, otherwise it would just create unnecessary empty space on the cart? So if I understand it right if you don't want to have a really fragmented cart you have to plan the parts beforehand and expand the size of a part later if needed?

post-2915-0-92299400-1473157612_thumb.png

Edited by Turbo Laser Lynx
Link to comment
Share on other sites

I'm doing fast progress on my demo but a couple of the sprites still have those weird artifacts / tears to the right of the sprites :( (that's what all the buggy sprites have in common). I feel I've tried everything. BPP 2 and 4, different modes, like normal, non collidable, literal sprite etc. I managed to get rid of the tear/artifacts on my main character when exporting pcx from gimp when switching between removing unused colours and not. Not removing unused colors, BPP4 and normal or collidable usually works fine so it drives me crazy that some images doesn't work for no apparent reason. Any help or pointer in the right direction how to fix this greatly appreciated.

Also one weird thing is that the intro title screen sprite looks ok in handy but has the tear on a real lynx.

 

*Edit: How weird, on a real Lynx the tear is only visible in the intro sprite, two other sprites that have artifacts look ok on a real lynx.

Edited by Turbo Laser Lynx
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...