Hallo Besucher, der Thread wurde 6,2k mal aufgerufen und enthält 27 Antworten

letzter Beitrag von syshack am

Generated CRT cartridge image works not - where I do the mistake?

  • Hi!


    I'm here new and really didn't knew where to place this topic.
    I'm 128er and for VICE emulator I created internal ROM for C128 and tried to create C64 cartridge for Commodore 64 emulator.
    In menu attach cartridge is possible to attach Generic, but only Game or Max cartridge, so my knowledge is lost.
    So, later I tried to convert generic cartridge (created by instructions in C128 manual) to CRT by cartconv of VICE, conversion was succesfull.
    But now again C64 cartridge works not, C128 internal works.
    So, where I do the mistake? Cartridge hangs computer. Cartridge purpose is for execute Z80 code without writting handler, simply call POKE780,LO:POKE781,HI:SYS40000




    And I attached CRT image.


    I hope anybody helps.
    Miro

  • The C128 handles the ROM-slot quite different than a C64 CRT. It does not search for a CBM80 at $8004, but for a CBM at $8009 or $C009 (depending on ROM size). If such a signature is found, the C128 will read $8008 or $C008 and test if it's $00, $01 or $02. Depending on the value there, it will do the following:


    $00 = C128 will not jump to the cartridge at all.
    $01 = C128 will jump to it early in the reset process.
    $02 = C128 will jump to it late in the reset process.


    There are also no jump vectors like on C64 CRTs, the C128 will simply JSR to $8000 or $C000.

  • Code
    1. *=$8000
    2. .byte $09, $80 ; Cold start vector
    3. .byte $09, $80 ; Warm start vector


    Fail.


    Zitat
    Code
    1. begin: sei
    2. jmp start
    3. start: nop
    4. nop
    5. rts ; @ $8009


    Epic fail.


    RTFCB64

  • Ok - thank you for explain and for link to Codebase.
    I modified it to:


    Now is possible to attach cartridge as 8K generic or CRT (generated by CARTCONV).
    Both have problem:
    After attaching to computer performs reset and hangs when ends my own code (code is only example, no more). When I perform reset, computer few moments hangs at the same point and then it looks like NMI happened - STOP+RESTORE - clear screen and in top left corner is READY.


    So, what it needs now? If will be solved this all will be ok - I need also make code possible to customize... and also make sure that Z80 code works


    Thank you boys all.
    Miro


    z64cart.bin, z64cart.crt

  • Are you trying to call the Z80 from a Cartridge? I think its not possible to call it from a C64 mode, only from C128.

    Yes, all MMU registers ($D5xx) disappear in C64 mode.


    Btw, one of the "incompabilities" of the C128 vs the C64, because on C64 that area contains SID register mirrors, while on C128 it doesn't. That's why some games don't have sound/music on C128, for example: Frantic Freddie.

  • Uh, I forgot main thing:
    When I enable CP/M cartridge in x64 and then attach this new - it detach CP/M :(
    Also is possible to have in VICE x64 attached 2 cartridges?
    But anyway - want to solve cartridge creation for C64...
    Z80 and C128 and C64:
    I own C128DCR with SCPU128 and CP/M cartridge.
    It allows me:
    in 128 mode - three CPUs - 8502, Z80 inside C128, Z80 inside cartridge, can run CP/M 3.0, if is SCPU on, disables internal Z80, replaces 8502 by 65816 and Z80 in cartridge works...
    in 64 mode - two CPUs - 8502, Z80 inside cartridge, can run CP/M 2.2, if is SCPU on, 8502 is replaced by 65816 and Z80 in cartridge works...
    All is tested, my C128 system works - with its 3 CPUs + 65816 CPU...


    If VICE allows not attach CP/M and one CRT I modify Kernal, but please explain me anybody how to make CRT working.
    Thank you all.

  • ok. I write it to sections
    Z80 & C64 & C128 & CP/M:
    Inside C128 is Z80 which works in C128 mode only and when is SCPU turned off
    Z80 inside CP/M cartridge works on C64, C128 in both modes (128 & 64) no matter if is SCPU turned on.
    This allows C128 have available 3 CPUs: 8502 and two Z80. In 128 mode can run CP/M 3.0, in 64 mode can run CP/M 2.2
    I'm owner of C128, SCPU and CP/M cartridge - so all is tested and if anyone wants to know more details, I can post it.


    My cartridge:
    purpose - direct execution Z80 code from Basic in x128 and x64 emulator.
    Cartridge, better to say EPROM for C128 internal socket is working. Only x128 emulates not CP/M cartridge, so that part is unused.
    Cartridge for C64 is created, in x64 can be enabled emulation of CP/M cartridge and attached cartridge together, at once. After attachment performs reset and hangs, after next and other resets hangs few seconds and then looks like performing NMI (Stop+Restore) - clears screen and in top left corner is READY. I tested not yet Z80 code.
    I need to solve that hang and NMI.


    I want to add also function to display start address of files without loading. For C128 I can add 2 commands to Basic 7.0 - SYSZ and LADR, for C64 I'm not able to do it.


    Miro

  • I want to add also function to display start address of files without loading. For C128 I can add 2 commands to Basic 7.0 - SYSZ and LADR, for C64 I'm not able to do it.

    You can also add in BASIC V2 additional BASIC commands, usually using a special character like @ and then followed by your command.


    There are examples on the net and in old books/magazines (e.g. on "The Transactor"). Here is one example:
    https://unlawfulassembly.wordp…nding-commodore-64-basic/

  • Last question first: to get a start address of a file in basic v2 it should be sufficient to open it, fetch the first two bytes and calculate the address. I haven't done this since ages, but it should be something like open1,8,1,"...":get#1,a$:get#1,b$:printasc(b$)*256+asc(a$):close#1 (assuming low-ordered byte is first). Well, it's explained in detail in the manual. It might be not a new command but enough to fulfill its purpose.


    For the execution of Z80 code I would concentrate on the x128 alone... switching between both CPUs should be available there. Or are you trying to use two CPUs at the same time?

  • I said that I don't know create new Basic commands - I know how to get first 2 bytes which are in CBM-DOS address bytes, also I can execute Z80 ML program directly from Basic.
    Only don't know how to add new Basic commands for Basic V2 - in this case is not enough to have special character as commands identifier, for example written above - JiffyDOS uses @.
    I created also AceDOS for Commodore 128 and there are new commands without any ID character - so, my knowledge around Basic V2 is low, in case Basic V7 higher.


    I can create functions LADR & SYSZ for C64 simply by calling SYS <address> and using addresses 780-783 for values of A,X,Y,S.
    Basic V7 has syntax of SYS command:
    SYS <address>,<accumulator>, <Xreg>,<Yreg>,<status>
    and also function
    RREG <accumulator>, <Xreg>,<Yreg>,<status>
    which reads current register values, for example by performing any SYS command user needs any value, it needs not to store it somewhere, it can be in any register and RREG reads it.


    But again to MAIN PROBLEM (I'm sorry for writting uppercase letters like moron, but this thread is now more about Z80, CP/M and Basic extension than was Q)
    How to correct CRT or BIN image to get it work?


    Cartridge for C64 is created, after attachment in x64 performs reset and hangs, after next and other resets hangs few seconds and then looks like performing NMI (Stop+Restore) - clears screen and in top left corner is READY. I tested not yet Z80 code.
    I need to solve that hang and NMI...


    Thank you for reading it all and please help me - I'm in C64 world like little kid.
    Miro

  • Tale-X
    Execution Z80 code on 128 is possible only by switch - C128 is designed to use only one CPU at once - when is switched 8502 to Z80, 8502's state, regs, stack etc. is freezed and Z80 can continue where was turned off or by calling parameters and both vice versa.


    But I own also CP/M cartridge with Z80.
    This CPU is not in C128 design.
    Switch to this CPU from 8502 works same way - turns off 8502 or 65816 but...
    I tried to call external Z80 from internal Z80 - here's other situation - Z80 stops Z80 not!
    It's not design for stop Z80. Call internal Z80 from external Z80 is not possible for different RAM and IO config.


    Calling external Z80 from internal Z80:
    This switch stops only 8502, but not directly by internal Z80 - by hardware design.
    When is switched to external Z80, internal Z80 continues (not verified) its work - no one signal to turn off. Turning off external Z80 calls 8502 - but what running internal Z80? Looks like no signal to turn off... crash?
    I tried to call ext. Z80 from int. Z80, but didn't knew to handle it... It is good theme to discussion and discovering - or maybe I'm only stupid moron which is proud to fake.
    Have I post extra thread for 8502 & two Z80s and my experience with? If, I do it on C128 forum or here (problem is my lack of German language) or both (sync problem) - so how?


    And please help me with C64 cartridge.
    Miro

  • With the crt-Issue I can't help - no experience so far.


    Regarding the co-operation of Z80s, well I think you might be the first one touching this topic. It's in my opinion worth a separate thread, but expect to be the only one who comes up with information. Which is not a matter of language, most people, especially those very familiar with the internals, understand english well. It's more that having a c128 made a cp/m extension card superfluous. And it takes good arguments to change this view (and convince 128 owner to get a cp/m card to follow your experience)

  • Ok, few things:
    I bought CP/M cartridge for one purpose only - SCPU makes internal Z80 unacessible and I like Z80, also support of Z80 in The Ace was weak. Now is available with SCPU and without SCPU twice also in 64 mode with or without SCPU.
    Later when began testing, I found new possibilities.
    This night I try to write small code to test handling both CPUs at once, but it will be not so easy.
    Miro

  • OK, first results.


    Tested were both Z80 separately and in both C128 modes - 128 and 64.
    Long time known thing is that calling missing Z80 never produces crash, for example - internal Z80 is not accessible while is SCPU turned on or in 64 mode.
    The same is for external Z80 - if is not present, code continues normally without crash.


    I created two separate routines for each Z80 - internal increment VIC border, external increment VIC paper.
    I tried them in all possible combinations with SCPU, CP/M cartridge, 64 mode etc. - all was working correctly.


    Then I started Dual Z80 routine.
    Yesterday routine starts and hanging computer. This was surprise 'cause before using handling code after switch from internal Z80 to external Z80 it always crashed.
    It was looking like code attempts to switch and continue, but hanging is not ok.
    This night I tried similar code.
    Routine starts in 8502 code to switch to internal Z80, then internal Z80 attempts switch to external Z80 and then continues with border increment.
    So, I was waiting for starting increment VIC paper by external Z80 and by internal Z80 increment VIC border at once.
    It works not - looks like switch to external Z80 is not succesfull. Ok, this can be waited, but why happened problems before?
    I was searching in resources and found that expansion port pin 7 allows to activate external Z80, there is CP/M cartridge connected and this is reason why can work with SCPU too. Running with SCPU requires only slow down to 1MHz while running Z80 code, only for switch sync. Internal Z80 is not possible to access with SCPU for hardware connection and in 64 mode disabling MMU.
    But here's Q - expansion port, especially pin 7, is maybe accessible by internal Z80, why to throw out hardware which can run with Z80...
    If is accessible it needs to find where and then switch it by that way. This switch produces signal to 8502 (or 6502) to turn off, but it was not designed to produce signal to turn off internal Z80 - so this fight I lost not yet.
    Many times is easy to find CP/M memory map - for your info - C128's CP/M3 handles whole 128K - many times I had to read that 64K only. And finding differences between CP/M memory map and 8502 memory map is not true for Z80 between 8502 - CP/M is operating system, example:
    CP/M uses for 40 column screen attributes area $1000-$1300 etc., but if you want to POKE by Z80 code any character to 40 column screen you must to use area $0400-$07E7 (by default).
    So comparing CP/M and 8502 memory maps is mismatch. It needs to compare Z80 between 8502 map.
    And differently is RAM mapped by internal and external Z80 - internal uses same addressing, but external Z80 has whole RAM shifted $1000 lower - and accessing switch there is $CE00 instead 8502/internal Z80 $DE00 - so external Z80 see pin 7, again reason why to search...
    Here it looks like no source to get where is mapped exp. port - or I can to use also not IO opcodes and try it again. Also 64 mode has not accessible MMU and other differences can make it not accessible, but CP/M cartridge I was using first time with C128 - I was warned that it's impossible to use and my results were succesfull and rewritten words in one SuperCPU FAQ page...
    Very important is in Z80 assembler to use correct opcodes - for IO IN and OUT and normally LD...
    I will experiment - this fight is not finished, not yet has winner.


    If anyone has knowledge or sources to mapping expansion port for Z80 in C128 - all suggestions are welcome and thank you all for help.


    Miro

  • So I tried also accessing address $DE00 not as IO location, again not working... Here's only one Q: Why can be expansion port not accessible for Z80?
    When I will have any help where in RAM is IO of exp.port placed, or anybody knows that Z80 see it not, this makes sense and final result.


    But really don't understand why Z80 cannot to see exp.port.
    True is that C64 see not MMU of C128 - but that's ok 'cause it never has
    Z80 was designed for C128 and can access 128K RAM, many of users think that only 64K.


    If anybody helps, will be very thankful.


    Miro