Jump to content
IGNORED

Speed-Programming Karri's Flashcard on the Lynx


MichelS

Recommended Posts

Posted (edited)

Can we see your shift out code? is this C?

 

//
void shiftbit(int srbit) {
delay_fast();
if (srbit == 0) {
SERDAT_PIN = 0;
} else {
SERDAT_PIN = 1;
} // srbit
delay_fast();
SRCLK_PIN = 1;
}
//
void shiftbyte() {
unsigned char srbuff = 0;
int srcnt= 0; // shift byte
for (srcnt=0 ; srcnt<8 ; ++srcnt) {
delay_fast();
SRCLK_PIN = 0;  
srbuff = srbyte << srcnt;
srbuff = srbuff & 0x80;
shiftbit(srbuff);
} // srcnt
}
//

 

In asm there'd be no need to copy srbit to serdatpin for example, but in C we have no bit variable type, and SERDAT_PIN is a bit so...

Also this mcu is 40MIPS, so my code has to pause so it isn't too fast for old stock logic chips! In asm there'd be no shiftbit function.

 

Also, why did you ever care? All games have been ripped. If it wasn't for a new particular game I wouldn't care less about this.

That shift register load pattern might be an interesting thought exercise though.

 

 

 

Edited by Brek Martin
Link to comment
Share on other sites

Posted (edited)

I'm coding ASM usually and the shifting code is nothing special

 

; --------------------------------------------------------------------------------
; _set_shifter (A: shifter value; X,Y: trashed)
; --------------------------------------------------------------------------------

_set_shifter:
                ldx #$02
                ldy #$03

                bit #$80
                beq :+
                stx $FD8B
                bra strobe7
:               stz $FD8B
strobe7:        sty $FD87
                stx $FD87

                bit #$40
                beq :+
                stx $FD8B
                bra strobe6
:               stz $FD8B
strobe6:        sty $FD87
                stx $FD87

...

                stz $FD8B
                rts

 

Just an unrolled loop. 
Usually you'd push/pull the registers onto the stack for subroutines, but i'm using this routine in a defined context where i do not need to keep the registers intact.
Also this routine requires the display to be off (i.e. video dma disabled) since otherwise the display will flicker.
This is since i'm zeroing "rest" in FD8B while shifting. If you'd want to keep "rest" active, you'd need more values (more than 0, 2 or 3) to write into FD87 and FD8B.
Since you only have the x- and y-register (accumulator is holding the value to be shifted in) you'd have to change register values.
 

Quote

Also this mcu is 40MIPS, so my code has to pause so it isn't too fast for old stock logic chips!

On Lynx you don't have to pause any code - it's only 2 MIPS.


And 2 MIPS is the theoretical maximum for do-nothing code and no video output and no dram refresh (so a short-lived thing) - regular asm code is more like 1 MIPS.
The Lynx has a 16 MHZ oscillator, so 16 million ticks/second. A 65c02 CPU takes 2 cycles (cycle != tick) minimum per instruction, a memory access usually takes 4 cycles.
A cycle is 4 or 5 ticks depending whether it's paged or not.
So even a simple implicit 'INC' instruction takes minimum 2 cycles with 4 ticks each = 8 ticks (9 if the opcode-fetch isn't paged)
Now - 16 million ticks / 8 ticks per instruction = 2 MIPS max.
But there's also ticks taken for dram refresh and video dma. And these also make the next instruction non-paged i.e slower...
 

Quote

Also, why did you ever care? All games have been ripped.

 

??? - This has nothing to do with ripping at all. I wasn't reading but writing a cartridge.

And when writing a byte to These flash chips you need to issue a byte-program command.

It's this command that makes programmng slow on the lynx since it requires kind of random access to different addresses. That's something the lynx can't easily do.

 

It was an experiment that got out of control.
I was just curious how fast you could get when (ab-)using the Lynx as a cartridge programmer.

Edited by MichelS
Link to comment
Share on other sites

This:

       bit #$80
       beq :+
       stx $FD8B
       bra strobe7
       stz $FD8B
strobe7:

 

can likely be changed to

 sta value 
 ldx #$02
 ldy #$03
 txa
 bbs7 value,_b7_1
 lda #0
_b7_1:
 sta $fd8b
 sty $FD87
 stx $FD87
 

 

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
Posted (edited)

It could just be a case of he doesn't know what language you're using, but is proficient with several,

so you show yours he shows his last shift register code, which happens to have been in a project for dsPic microcontroller,

Externally clocked with an 8Mhz crystal, and internally PLLed so the CPU runs at 40MIPS give or take some PLL jitter.

 

So even if it were C code for a Lynx, it is flawed for having pauses.

 

Cart dumper/Cart programmer. It's only the human that derives comfort from the pages being addressed chronologically.

 

Edited by Brek Martin
Link to comment
Share on other sites

  • 1 month later...
Posted (edited)
On 5/15/2024 at 4:52 PM, 42bs said:

can likely be changed to

 sta value 
 ldx #$02
 ldy #$03
 txa
 bbs7 value,_b7_1
 lda #0
_b7_1:
 sta $fd8b
 sty $FD87
 stx $FD87
 

 


Is this working on a Lynx I? I actually never tried and I don't have a working one at hand for testing it.

Edited by obschan
Link to comment
Share on other sites

4 hours ago, obschan said:


Is this working on a Lynx I? I actually never tried and I don't have a working one at hand for testing it.

BBSx does not work on original Lynx as it is only a 65SC02 not an 65C02 as the later Lynx II. Non-stereo Lynx II also lack these instructions.

  • Like 1
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...