Brek Martin Posted May 14 Share Posted May 14 (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 May 14 by Brek Martin Quote Link to comment Share on other sites More sharing options...
MichelS Posted May 15 Author Share Posted May 15 (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 May 19 by MichelS Quote Link to comment Share on other sites More sharing options...
42bs Posted May 15 Share Posted May 15 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 1 Quote Link to comment Share on other sites More sharing options...
Brek Martin Posted May 25 Share Posted May 25 (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 May 25 by Brek Martin Quote Link to comment Share on other sites More sharing options...
obschan Posted July 7 Share Posted July 7 (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 July 7 by obschan Quote Link to comment Share on other sites More sharing options...
42bs Posted July 7 Share Posted July 7 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. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.