Skip to content

Commit a694f45

Browse files
committed
changes to 1.1
1 parent b6ef043 commit a694f45

9 files changed

Lines changed: 1593 additions & 1583 deletions

File tree

MakeDiskImage/MakeDiskImage.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,6 @@ int main()
7777
addFile(path + L"MakeDiskImage\\PaulaNET.device.info", "PaulaNET.device.info", vol); // Add the driver icon
7878

7979

80-
81-
// Add icons
82-
// addFile(L"D:\\PaulaNET\\MakeDiskImage\\MakeDiskImage.cpp", "test2.txt", vol);
83-
// addFile(L"D:\\PaulaNET\\MakeDiskImage\\MakeDiskImage.cpp", "test3.txt", vol);
84-
// addFile(L"D:\\PaulaNET\\MakeDiskImage\\MakeDiskImage.cpp", "test4.txt", vol);
85-
// addFile(L"D:\\PaulaNET\\MakeDiskImage\\MakeDiskImage.cpp", "test5.txt", vol);
86-
// addFile(L"D:\\PaulaNET\\MakeDiskImage\\MakeDiskImage.cpp", "test6.txt", vol);
87-
// addFile(L"D:\\PaulaNET\\MakeDiskImage\\MakeDiskImage.cpp", "test7.txt", vol);
88-
// addFile(L"D:\\PaulaNET\\MakeDiskImage\\MakeDiskImage.cpp", "test8.txt", vol);
89-
9080
adfVolUnMount(vol);
9181

9282
adfDevUnMount(device);

NetDevice/paulanetio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,8 @@ BOOL paulaNetReceivePackets(APTR device, APTR userContext, PacketReceivedCallbac
933933
struct PacketsHeader pkHeader;
934934
mfmDecode(pkt, sizeof(struct PacketsHeader)*2, (UBYTE*)&pkHeader, sizeof(struct PacketsHeader));
935935
pkt += sizeof(struct PacketsHeader);
936-
UWORD* pktEnd = (UWORD*)(((UBYTE*)pkt) + ((header.dataSize - 4)<<1));
936+
//UWORD* pktEnd = (UWORD*)(((UBYTE*)pkt) + ((header.dataSize - 4)<<1));
937+
UWORD* pktEnd = (UWORD*)(((UBYTE*)pkt) + header.dataSize - (sizeof(struct PacketsHeader)<<1));
937938

938939
// Skip if we've already seen this data
939940
if (dev->lastPicoCounter == header.picoCounter) {

NetDevice/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#define _INC_VERSION_H
33

44
#define DEVICEVERSION 1
5-
#define DEVICEREVISION 0
5+
#define DEVICEREVISION 1
66
#define DEVICEEXTRA
77

8-
#define DEVICEDATE 2026-05-11
8+
#define DEVICEDATE 2026-06-13
99

1010
#endif

Pico/PaulaNET/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (EXISTS ${picoVscode})
2323
include(${picoVscode})
2424
endif()
2525
# ====================================================================================
26-
set(PICO_BOARD pico_w CACHE STRING "Board type")
26+
set(PICO_BOARD pico2_w CACHE STRING "Board type")
2727

2828
# Pull in Raspberry Pi Pico SDK (must be before project)
2929
include(pico_sdk_import.cmake)

Pico/PaulaNET/DiskImage.cpp

Lines changed: 1549 additions & 1533 deletions
Large diffs are not rendered by default.

Pico/PaulaNET/PaulaNET.cpp

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Head Selection:
5050
*/
5151

5252
#define MAJOR_VERSION 1
53-
#define MINOR_VERSION 0
53+
#define MINOR_VERSION 1
5454

5555

5656
#define PIN_LED_PAULAIO 17 // Data from/to paula
@@ -416,8 +416,7 @@ void __not_in_flash_func(pinMonitor)(uint gpio, uint32_t events) {
416416
case PIN_SELECT:
417417
isSelected = (events & GPIO_IRQ_EDGE_FALL) != 0;
418418
// Motor state is latched on select
419-
if (isSelected) isMotorActive = gpio_get(PIN_MOTOR) == 0;
420-
gpio_set_dir(PIN_READDATA, isSelected ? GPIO_OUT : GPIO_IN);
419+
if (isSelected) isMotorActive = gpio_get(PIN_MOTOR) == 0;
421420
gpio_set_dir(PIN_TRACK0, isSelected ? GPIO_OUT : GPIO_IN);
422421
gpio_set_dir(PIN_WRITEPROTECT, isSelected ? GPIO_OUT : GPIO_IN);
423422
gpio_set_dir(PIN_DISKCHANGE, isSelected ? GPIO_OUT : GPIO_IN);
@@ -491,16 +490,13 @@ void setupDriveSelectPIO(uint selectPin, uint readyPin) {
491490

492491
sm_config_set_in_pins(&c, selectPin);
493492
sm_config_set_set_pins(&c, readyPin, 1);
494-
495-
// Full speed - we want minimum latency
496493
sm_config_set_clkdiv(&c, 1.0f);
497494

498495
pio_gpio_init(pioDriveSelect.pio, readyPin);
499-
pio_sm_set_consecutive_pindirs(pioDriveSelect.pio, pioDriveSelect.sm, readyPin, 1, true); // ready = output
500-
// selectPin stays as input, no pindirs change needed
496+
pio_sm_set_pins_with_mask(pioDriveSelect.pio, pioDriveSelect.sm, 0, 1u << readyPin);
497+
pio_sm_set_consecutive_pindirs(pioDriveSelect.pio, pioDriveSelect.sm, readyPin, 1, false);
501498

502499
pio_sm_init(pioDriveSelect.pio, pioDriveSelect.sm, offset, &c);
503-
pio_sm_exec(pioDriveSelect.pio, pioDriveSelect.sm, pio_encode_set(pio_pins, 1));
504500
pio_sm_set_enabled(pioDriveSelect.pio, pioDriveSelect.sm, true);
505501
}
506502

@@ -775,7 +771,7 @@ void preparePacketsToTransmit() {
775771
return;
776772
}
777773
lastPicoCounter++;
778-
774+
779775
// Pointer to whre data starts
780776
uint8_t* headerStart = (uint8_t*)&PacketBackup[ PAULA_INDEX_PADDING + 4];
781777
uint8_t* dataStart = headerStart + (sizeof(DataHeader)*2);
@@ -1013,18 +1009,22 @@ uint32_t readFromPaula() {
10131009
void setupWritingPIO(uint pin) {
10141010
#ifdef PICO_RP2350
10151011
uint offset = pio_add_program(pioFloppyTX.pio, &floppy_tx_pico2_program);
1012+
pio_sm_config c = floppy_tx_pico2_program_get_default_config(offset);
10161013
#else
10171014
uint offset = pio_add_program(pioFloppyTX.pio, &floppy_tx_program);
1018-
#endif
10191015
pio_sm_config c = floppy_tx_program_get_default_config(offset);
1016+
#endif
10201017
sm_config_set_out_shift(&c, false, true, 16); // shift left, autopull, 16 bits
10211018
sm_config_set_set_pins(&c, pin, 1);
10221019
sm_config_set_clkdiv(&c, 8); // 125MHz/8 = 15.625MHz
10231020

1024-
pio_sm_set_consecutive_pindirs(pioFloppyTX.pio, pioFloppyTX.sm, pin, 1, true);
10251021
pio_gpio_init(pioFloppyTX.pio, pin);
10261022
pio_sm_init(pioFloppyTX.pio, pioFloppyTX.sm, offset, &c);
1027-
pio_sm_set_enabled(pioFloppyTX.pio, pioFloppyTX.sm, true);
1023+
1024+
// After init - output value permanently 0, start high-Z
1025+
pio_sm_set_pins_with_mask(pioFloppyTX.pio, pioFloppyTX.sm, 0, 1u << pin);
1026+
pio_sm_set_consecutive_pindirs(pioFloppyTX.pio, pioFloppyTX.sm, pin, 1, false);
1027+
// Don't enable - only enable when transmitting
10281028
}
10291029

10301030
// Core 1 MAIN
@@ -1064,12 +1064,17 @@ void core1Main() {
10641064
while ((currentTrack == track) && (currentSide == isLowerSide()) && (isSelected) && (isMotorActive) && gpio_get(PIN_RESET)) {
10651065
// Start transmission
10661066
gpio_put(PIN_INDEX, 0); // index is used to help sync the data stream
1067+
pio_sm_set_consecutive_pindirs(pioFloppyTX.pio, pioFloppyTX.sm, PIN_READDATA, 1, true);
1068+
pio_sm_set_enabled(pioFloppyTX.pio, pioFloppyTX.sm, true);
10671069
dma_channel_configure(dma_chan, &cfg, &pioFloppyTX.pio->txf[pioFloppyTX.sm],IoBuffer,bufferUsed,true);
10681070
sleep_us(3000); // wait 3ms, this allows the index to work properly.
10691071
gpio_put(PIN_INDEX, 1);
10701072
// Wait for one of these states to change
1071-
while ((currentTrack == track) && (currentSide == isLowerSide() && (isSelected) && (isMotorActive) && gpio_get(PIN_RESET) && dma_channel_is_busy(dma_chan)));
1073+
while ((currentTrack == track) && (currentSide == isLowerSide()) && (isSelected) && (isMotorActive) && gpio_get(PIN_RESET) && dma_channel_is_busy(dma_chan));
10721074
dma_channel_abort(dma_chan);
1075+
pio_sm_clear_fifos(pioFloppyTX.pio, pioFloppyTX.sm);
1076+
pio_sm_set_enabled(pioFloppyTX.pio, pioFloppyTX.sm, false);
1077+
pio_sm_set_consecutive_pindirs(pioFloppyTX.pio, pioFloppyTX.sm, PIN_READDATA, 1, false);
10731078
}
10741079
gpio_put(PIN_LED_PAULAIO, 0);
10751080
}
@@ -1109,13 +1114,18 @@ void core1Main() {
11091114
while ((!isLowerSide()) && (isSelected) && gpio_get(PIN_RESET) && isMotorActive && (currentTrack == track)) {
11101115
// Start transmission
11111116
gpio_put(PIN_INDEX, 0); // index is used to help sync the data stream
1117+
pio_sm_set_consecutive_pindirs(pioFloppyTX.pio, pioFloppyTX.sm, PIN_READDATA, 1, true);
1118+
pio_sm_set_enabled(pioFloppyTX.pio, pioFloppyTX.sm, true);
11121119
dma_channel_configure(dma_chan, &cfg, &pioFloppyTX.pio->txf[pioFloppyTX.sm], (paulaMode == PaulaMode::pmEthernet) ? PacketBackup : IoBuffer,bufferUsed,true);
11131120
sleep_us(1000); // wait 1ms, this allows the index to work properly.
11141121
gpio_put(PIN_INDEX, 1);
11151122

11161123
// Wait for one of these states to change
1117-
while ((!isLowerSide()) && (isSelected) && dma_channel_is_busy(dma_chan) && gpio_get(PIN_RESET) && isMotorActive && (currentTrack == track));
1124+
while ((currentTrack == track) && (!isLowerSide()) && (isSelected) && (isMotorActive) && gpio_get(PIN_RESET) && dma_channel_is_busy(dma_chan));
11181125
dma_channel_abort(dma_chan);
1126+
pio_sm_clear_fifos(pioFloppyTX.pio, pioFloppyTX.sm);
1127+
pio_sm_set_enabled(pioFloppyTX.pio, pioFloppyTX.sm, false);
1128+
pio_sm_set_consecutive_pindirs(pioFloppyTX.pio, pioFloppyTX.sm, PIN_READDATA, 1, false);
11191129
}
11201130
gpio_put(PIN_LED_PAULAIO, 0);
11211131
}
@@ -1399,9 +1409,11 @@ int main() {
13991409
// Prep compress and encode each packet for transmission
14001410
if (settings.flags & FLAGS_PICO_COMPRESSION) {
14011411
// Experimental LZ4 compressor
1402-
//compressedRxQueue.packets[compressedRxQueue.writeIndex].length = lz4Compress(rxQueue.packets[rxQueue.readIndex].data, rxQueue.packets[rxQueue.readIndex].length, outputPosition, true, (uint16_t*)Core0RunBuffer);
1412+
//size_t realSize;
1413+
//compressedRxQueue.packets[compressedRxQueue.writeIndex].length = lz4Compress(rxQueue.packets[rxQueue.readIndex].data, rxQueue.packets[rxQueue.readIndex].length, outputPosition, true, (uint16_t*)Core0RunBuffer, &realSize);
1414+
14031415
compressedRxQueue.packets[compressedRxQueue.writeIndex].length = rleCompress(rxQueue.packets[rxQueue.readIndex].data, rxQueue.packets[rxQueue.readIndex].length, outputPosition, true, Core0RunBuffer);
1404-
hdr.compressedSize = SWAP16(compressedRxQueue.packets[compressedRxQueue.writeIndex].length);
1416+
hdr.compressedSize = SWAP16(compressedRxQueue.packets[compressedRxQueue.writeIndex].length/*realSize*/);
14051417
// WORD padding
14061418
if (compressedRxQueue.packets[compressedRxQueue.writeIndex].length&1) {
14071419
*(outputPosition+compressedRxQueue.packets[compressedRxQueue.writeIndex].length) = 0;

Pico/PaulaNET/floppytx.pio

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ top:
33
.wrap_target
44
out x, 1 [14] ; shift bit into X, burn 15 cycles
55
jmp !x no_pulse ; if X=0, no pulse 1 cycle
6-
set pins, 0 [4] ; 5 cycles high = 256ns
7-
set pins, 1 [9] ; 10 cycles low
6+
set pindirs, 1 [4] ; 5 cycles high = 256ns
7+
set pindirs, 0 [9] ; 10 cycles low
88
jmp top ; 1 cycle
99
no_pulse:
1010
nop [15] ; burn 16 cycles
@@ -16,8 +16,8 @@ top:
1616
.wrap_target
1717
out x, 1 [17] ; 18 cycles
1818
jmp !x no_pulse ; if X=0, no pulse 1 cycle
19-
set pins, 0 [4] ; 5 cycles
20-
set pins, 1 [11] ; 12 cycles
19+
set pindirs, 1 [4] ; 5 cycles
20+
set pindirs, 0 [11] ; 12 cycles
2121
jmp top ; 1 cycle
2222
no_pulse:
2323
nop [16] ; 17 cycles
@@ -28,9 +28,9 @@ no_pulse:
2828
.program drive_select
2929
.wrap_target
3030
wait 0 pin 0 ; wait for SELECT to go low (asserted)
31-
set pins, 0 ; immediately assert READY
31+
set pindirs, 1 ; immediately assert READY
3232
wait 1 pin 0 ; wait for SELECT to go high (deasserted)
33-
set pins, 1 ; immediately deassert READY
33+
set pindirs, 0 ; immediately deassert READY
3434
.wrap
3535

3636

Pico/PaulaNET/rleCompression.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ uint16_t rleCalcDecompressSize(const uint8_t* src, uint16_t srclen) {
129129
return dstSize;
130130
}
131131

132-
/*
133132

134133
// Experimental LZ4 compression Pico->Amiga direction only
135134

@@ -195,7 +194,7 @@ static uint16_t emitSequence(uint8_t* dst, uint16_t dstPos, const uint8_t* liter
195194
// hashBuffer must be LZ4_HASH_SIZE * sizeof(uint16_t) bytes (2KB).
196195
// Returns compressed size, or 0 on failure (dst too small).
197196
// wordSwap byte-swaps output words, matching your RLE option.
198-
size_t lz4Compress(const uint8_t* src, uint16_t srcLen, uint8_t* dst, bool wordSwap, uint16_t* hashBuffer) {
197+
size_t lz4Compress(const uint8_t* src, uint16_t srcLen, uint8_t* dst, bool wordSwap, uint16_t* hashBuffer, size_t* compressedSize) {
199198
// Clear hash table (positions default to 0 = unset, we use 0xFFFF as invalid)
200199
memset(hashBuffer, 0xFF, LZ4_HASH_SIZE * sizeof(uint16_t));
201200

@@ -220,7 +219,7 @@ size_t lz4Compress(const uint8_t* src, uint16_t srcLen, uint8_t* dst, bool wordS
220219
if (read32(&src[ref]) == v) {
221220
// Extend match forward
222221
uint16_t matchLen = LZ4_MIN_MATCH;
223-
uint16_t maxMatch = srcLen - srcPos;
222+
uint16_t maxMatch = (srcLen - LZ4_LAST_LITERALS) - srcPos;
224223
if (maxMatch > LZ4_LAST_LITERALS) maxMatch -= LZ4_LAST_LITERALS;
225224
while (matchLen < maxMatch && src[srcPos + matchLen] == src[ref + matchLen])
226225
matchLen++;
@@ -243,22 +242,14 @@ size_t lz4Compress(const uint8_t* src, uint16_t srcLen, uint8_t* dst, bool wordS
243242
uint16_t finalLitLen = srcLen - litStart;
244243
dstPos = emitSequence(dst, dstPos, &src[litStart], finalLitLen, 0, 0);
245244

246-
// Must be even
247-
bool dec = false;
248-
if (dstPos & 1) {
249-
uint8_t i = dst[dstPos];
250-
dst[dstPos++] = i;
251-
dec = true;
252-
}
245+
*compressedSize = dstPos;
246+
if (dstPos & 1) dst[dstPos++] = 0;
253247

254248
if (wordSwap) {
255249
uint16_t* p = (uint16_t*)dst;
256250
for (int i = 0; i < dstPos; i += 2) { *p = (*p >> 8) | (*p << 8); p++; }
257251
}
258252

259-
if (dec) dstPos--;
260-
261253
return dstPos;
262254
}
263255

264-
*/

Pico/PaulaNET/rleCompression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ uint16_t rleDecompress(const uint8_t* src, uint16_t srclen, uint8_t* dst, uint16
3535
uint16_t rleCalcDecompressSize(const uint8_t* src, uint16_t srclen);
3636

3737
// Experimental LZ4 compressor
38-
//size_t lz4Compress(const uint8_t* src, uint16_t srcLen, uint8_t* dst, bool wordSwap, uint16_t* hashBuffer);
38+
size_t lz4Compress(const uint8_t* src, uint16_t srcLen, uint8_t* dst, bool wordSwap, uint16_t* hashBuffer, size_t* compressedSize);
3939

4040
#endif

0 commit comments

Comments
 (0)