fnuecke / Circuity

Other
10 stars 0 forks source link

Block that can upload/download (at least) EEPROMs #16

Open fnuecke opened 8 years ago

fnuecke commented 8 years ago

Similar to the electronics library (or what it was called) in BC, a block that can be used to upload/download data from storage media.

Bonus: not only browse predefined directory but also allow selecting arbitrary files with a file chooser dialog? Kills fullscreen, but would be rather useful since it'll often be easier to cross-compile stuff and then upload it rather than compile it in-game.

iamgreaser commented 7 years ago

I came up with a concept that might actually work. Did a quick draft, and it's nice and simple. As an added bonus, it also has a mode where it can be used over the bus by a CPU, and because of this, I've also included two nice and simple bootloaders.

PhoneTape(TM)(R)(C)(P)(9) System
DRAFT #02
PhoneTape contains 1 EEPROM slot, and a way to upload/download arbitrary data from your computer,
either to/from the EEPROM or from whatever manually probes the bus.
UI:
- EEPROM slot
- Target selector switch (EEPROM, Bus)
- Play button (upload to MC server from client's disk)
- Record button (download from MC server to client's disk)
(considering swapping the meanings of these? or giving them different icons)
I/O interface: 4 bytes long, suggested location is IOBASE+0x30
00: Status (currently all RO):
    - bit 0 (RO): 1 = PhoneTape ready for upload to MC
    - bit 1 (RO): 1 = PhoneTape ready for download from MC
    - bit 2 (RO): 1 = PhoneTape in EEPROM mode, 0 = PhoneTape in Bus mode
    - all others: SHOULD BE ZERO

01: Data read/write
    If not ready for download from MC, writes are ignored.
    If not ready for upload to MC, reads return 0xFF.
02 03: Length (LE)
    If downloading from MC, write this, then wait for bit 1 to be set.
    - If bit 0 gets set instead, write this again to clear the state.
    If uploading to MC, wait for bit 0 to be set, then read this.
    If you need to handle more than 65535 bytes, use a different system.
When in EEPROM mode, length is fixed to 4KB, and the bus cannot use the PhoneTape.
LOADERS:
None of these are tested.
Z80: (and yes, as you may be able to tell, I like WLA-DX)
    ; Wait until upload ready
    -:
    in a, ($30) ; F100
    bit 0, a ; F102
    jr z, - ; F104
    ; Get length
    in a, ($32) ; F106
    ld c, a ; F108
    in a, ($33) ; F109
    ld b, a ; F10B
    ; Load from tape into 0x0000
    ; A faster loop could be used but this is easier to manage
    ; Of course, if you want a faster loop, the OTIR op is what you want
    ld hl, 0x0000 ; F10C
    -:
    in a, ($31) ; F10F
    ld (hl), a ; F111
    inc hl ; F112
    dec bc ; F113
    ld a, c ; F114
    and b ; F115
    jr nz, - ; F116
    ; Enter at 0x0000
    jp $0000 ; F118
    ; F11B - 27 bytes
MIPS3: (here I use gas)
    .set noreorder
    /* Use $t9 for I/O base */
    lui $t9, 0xA001
    /* Wait until upload ready */
    1:
    lb $t0, 0x30($t9)
    andi $t0, $t0, 0x0001
    beq $0, $t0, 1b
    nop
    /* Get length */
    lhu $t1, 0x32($t9)
    /* Load from tape into 0xA0000000 */
    lui $t2, 0xA000
    ori $t4, $t2, 0x0400
    2:
    lb $t0, 0x31($t9)
    sb $t0, 0($t2)
    addiu $t1, $t1, -1
    bne $0, $t1, 2b
    addiu $t2, $t2, 1
    /* Enter at 0xA0000400 (i.e. skip over the exception vectors) */
    jr $t4
    nop
    /* 15 ops - 60 bytes */
    .set reorder
fnuecke commented 7 years ago

That's... a lot more "in-world" than what I thought of :P

I was thinking more of a "plop in EEPROM, use Java-side API to read/swap out its binary blob" approach. In particular because that then doesn't required a working setup in-place to get one's boot ROM onto the server and such.

For larger data (tapes?) that would make a lot of sense though. Or even a generalized "internet card alternative" maybe? (Not sure I even want internet access in this mod though...)

iamgreaser commented 7 years ago

I was thinking more of a "plop in EEPROM, use Java-side API to read/swap out its binary blob" approach.

That's what the "EEPROM" setting on the EEPROM / Bus switch is for.

How big will the EEPROMs be, anyway? I still think 4KB should be enough, just because you'll want to boot some actually useful stuff off a disk... or off a PhoneTape system in Bus mode.

Or even a generalized "internet card alternative" maybe? (Not sure I even want internet access in this mod though...)

Get S3 onto this project (I don't remember the GitHub account or even if I ever knew it). Yes, I am talking about the guy responsible for the ATM-inspired cross-MC-server protocol/software suite OCRANET. But even if you aren't interested in any of it leaving the server, it'll still be worthwhile having a good yet simple networking system.

fnuecke commented 7 years ago

switch

Oh, I missed that part, my bad.

size

The 4K was just a number that didn't sound too out of this world, tbh. If it's reasonable, absolutely, let's stick with that.

networking magic

Oh, absolutely, an in-world way of networking would be a desirable module. While I don't want/want to encourage several dozens of computers in the world (rather a few central ones), more than one are certainly to be expected, so this would make perfect sense to have. If you run across him on IRC by all means, point him to this. If I do, so will I. If he's interested, we can make an issue for discussing networking (and the possibility for internet access).