Jump to content
IGNORED

Lynx Multi Cart


SainT

Recommended Posts

Here we go. The code is marked with "THIS WORKS" and "THIS FAILS". I've never used 6502, and it's rather limited to compared to the assembly I'm used to, so it's not that easy for me to debug. Any thoughts appreciated! :)

 

typedef struct
{
char szFilename[13];
u8 bDirectory;
} SDirEntry;


; ---------------------------------------------------------------
; void __near__ strcpy (__near__ unsigned char*, __near__ const unsigned char*)
; ---------------------------------------------------------------


.segment "CODE"


.proc _strcpy: near


.segment "BSS"


L007C:
.res 1,$00


.segment "CODE"


;
; c = *p2++;
;
L007D: ldy     #$01
jsr     ldaxysp
sta     regsave
stx     regsave+1
ina
bne     L0082
inx
L0082: ldy     #$00
jsr     staxysp
lda     regsave
ldx     regsave+1
ldy     #$00
jsr     ldauidx
sta     L007C
;
; *p1++ = c;
;
ldy     #$03
jsr     ldaxysp
sta     regsave
stx     regsave+1
ina
bne     L0084
inx
L0084: ldy     #$02
jsr     staxysp
lda     regsave
ldx     regsave+1
jsr     pushax
ldx     #$00
lda     L007C
ldy     #$00
jsr     staspidx
;
; } while (c != 0);
;
ldx     #$00
lda     L007C
cmp     #$00
jsr     boolne
jne     L007D
;
; }
;
jsr     incsp4
rts


.endproc


; ---------------------------------------------------------------
; void __near__ AddDirEntry (__near__ const unsigned char*, unsigned char)
; ---------------------------------------------------------------


.segment "CODE"


.proc _AddDirEntry: near


.segment "BSS"


L0088:
.res 1,$00


.segment "CODE"


;
; u8 nEntry = 0;
;
ldx     #$00
lda     #$00
sta     L0088
;
; gsDirEntry[0].szFilename[0] = 'a';
;
ldx     #$00
lda     #$61
sta     _gsDirEntry                       ; THIS WORKS
;
; gsDirEntry[0].szFilename[1] = 0;
;
ldx     #$00
lda     #$00
sta     _gsDirEntry+1                     ; THIS WORKS
;
; strcpy(gsDirEntry[0].szFilename, pIn);
;
lda     #<(_gsDirEntry)
ldx     #>(_gsDirEntry)
jsr     pushax
ldy     #$04
jsr     ldaxysp
jsr     _strcpy                           ; THIS FAILS
;
; ganDirOrder[nEntry] = gnNumDirEntries;
;
lda     #<(_ganDirOrder)
ldx     #>(_ganDirOrder)
clc
adc     L0088
bcc     L0098
inx
L0098: jsr     pushax
ldx     #$00
lda     _gnNumDirEntries
ldy     #$00
jsr     staspidx
;
; gnNumDirEntries++;
;
ldx     #$00
lda     _gnNumDirEntries
pha
ina
sta     _gnNumDirEntries
pla
;
; }
;
jsr     incsp3
rts


.endproc

Edited by SainT
Link to comment
Share on other sites

Ok, figured it out. The code generated is for __fastcall__ parameter passing, but the functions are not declared as __fastcall__, so it's all ballsed up. If you mark all functions which take parameters as __fastcall__ then all is good! This seems like a fairly major bug to me, I'm amazed this hasn't been spotted before?

  • Like 2
Link to comment
Share on other sites

If you include <string.h> then you don't have a problem.

 

--

Karri

Cheers Karri, I'll have a look at that later on -- do you mean because the functions in the standard libs are declared with fastcall? Or is there some pragma in there which sets fastcall to default?

 

The biggest issue for me is that using this c compiler as you would any other currently results in broken code. If you happen to miss the fastcall declaration off a function with parameters the code generated is just broken... Not a problem for a tiny project like the menu, but I quite fancied writing some games for the Lynx should I ever get time. And confidence in the tool chain is a must! :)

Link to comment
Share on other sites

The standard header files are different - not broken.

 

I am not sure how __fastcall__ started. It saves a few pushes and pops from the stack on every call. The parameters are in registers instead of on the stack.

 

The functions are declared correctly in the appropriate header files. So you should just avoid doing your own

 

extern int somefunction();

 

and use the definitions provided by the cc65/include directory.

 

This is a small inconvenience that results in faster and smaller code. Unfortunately it is not possible to get rid of __fastcall__ anymore as most asm code relies on this. And almost all cc65 code uses the __fastcall__ syntax today.

 

Sorry about this.

 

--

Karri

Link to comment
Share on other sites

It is well known on the cc65 side... I guess mostly people use the provided header files with function declarations and don't provide their own usually. I remember having this issue a long time ago myself, due to not having the function declaration for some system function (I think cgetc).

 

As Karri said, the __fastcall__ syntax is a cc65 addition that makes for smaller and faster code. Glad you got it figured out!

 

Check out this page for other tips on using cc65:

http://cc65.github.io/doc/coding.html

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

There's not much work left to do, but it's stupidly busy at work still, so I've still not been able to build up the enthusiasm to get stuck into it again yet. Will be busy for another four weeks or so I'd guess, we're nearly at gold master, so super bug fixing time.

Link to comment
Share on other sites

Ok, found some time to have a play. I have it working now -- got a directory browser written which will then launch LNX ROM images.

 

There's a couple of weird things still to iron out -- writing to the cart seems a bit flaky. I've managed to get it working with a massive delay loop, just need to figure out what the actual problem is. Seems to be some noise on the data lines, perhaps caused by polling the AUDIN pin? Not sure.

 

The other odd thing is that some games have no audio when launched from the file menu, but are just fine when launched directly. I assume I'm going to have to try and reset all the hardware to a power-on state before jumping to the boot ROM...

  • Like 11
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...

I've never gave the Lynx handheld a serious look until I saw this Video by Roli. The fact it can now be used on a larger screen is extremely appealing to me. I will be purchasing the mod now thanks to this video, but I had a question unrelated to the Multi Cart.

 

How will the model 2 Atari Lynx Handheld work with the mod installed on one lynx model 2 handheld on a big screen, if I was to use a second model 2 Lynx handheld with the LINK CABLE installed for '2 players' on a big screen? (If at all)

 

Is this possible? And if it is possible, then I'd obviously research on what games were compatible for 2 or more players….

 

I'm assuming the mod would display that of one handheld only, but since I've not owned a Lynx before, I feel the question has to be asked.

Link to comment
Share on other sites

I've never gave the Lynx handheld a serious look until I saw this Video by Roli. The fact it can now be used on a larger screen is extremely appealing to me. I will be purchasing the mod now thanks to this video, but I had a question unrelated to the Multi Cart.

 

How will the model 2 Atari Lynx Handheld work with the mod installed on one lynx model 2 handheld on a big screen, if I was to use a second model 2 Lynx handheld with the LINK CABLE installed for '2 players' on a big screen? (If at all)

 

Is this possible? And if it is possible, then I'd obviously research on what games were compatible for 2 or more players….

 

I'm assuming the mod would display that of one handheld only, but since I've not owned a Lynx before, I feel the question has to be asked.

 

I don´t kow if I understood your question right, but for a 2nd Lynx you would need a 2nd monitor, but keep in mind that the low Lynx resolution does not look that great on a huge VGA monitor.

I think for questions regarding the mod we better should use that existing thread: http://atariage.com/forums/topic/233632-lynx-lcd-replacementvga-out-by-mcwill/

 

I hope that the Lynx multicart will be finalized soon and as I show all kinds of multicarts and flashcarts on my Youtube channel, i would like to show also that one of course. :-D

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

AFAIK none of the Lynx comlinked game shares one display. Each player has their own display. So you will need LCD mod for each Lynx and separate VGA monitor each. There is one theoretical possibility: if you know of a video multiplexor that takes multiple video input and display them on one screen it could be used for Lynx. Those are commonly used for CCTV to show multiple security camera onto one display for easier monitoring. I don't know if there are VGA muxer or if you would need multiple VGA to composite converter for each Lynx.

 

Get a nice 100" LCD display and a 9-ways muxer and everyone can see up to 8 players at once (most are 2-4 players, one can do 8 players but theoretically Lynx can have unlimited players due to design of the cable but realistically the lag will kill massive multi-Lynx network)

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...