Last modified on 9 October 2013, at 08:00

No$cart

Revision as of 08:00, 9 October 2013 by Arnoldemu (Talk | contribs) (BASIC patches)

A utility by Nocash which converts a disk image to a cartridge.

http://nocash.emubase.de/

The tool hasn't been tested on the GX4000 so cartridges that are created may not work on it. You should test this to be sure.

In addition if the game/program has any of the following it will not work on GX4000:

  • It uses keyboard or requires keyboard input to get into the game
  • It uses 128K ONLY (or it's a bad "crack" that requires 128K to work even though the game itself would work in 64K).

However, the tool is easy for the non-programmer to use.

Technical

The created cartridge image has the OS, BASIC and Amsdos embedded in it and the data from the disk image (tracks/sectors).

Page 0 is OS.
Page 1 is BASIC.
Page 2 contains part of the disk image data.
Page 3 contains AMSDOS.
Page 4 onwards contains disk image data.

The OS, BASIC and AMSDOS are based on CPC6128 ROMs and have all been patched.

OS patches

The OS ROM has been patched in the following way:

  • Offset &67D has changed from:
call &0723
call &06fc
ld hl,&0688
jr   &6fc

to:

call &b900   ;; enable upper rom
ld bc,&df07  ;; select upper rom (7 - normally DOS/AMSDOS)
out (c),c
jp &dc03     ;; call into DOS/AMSDOS rom

  • Offset: &1052 and &1053 which define the first 2 colours of the "1st" palette have been changed from &04 to &14. The "1st" and "2nd" palette are swapped between in BASIC to implement flashing colours. &04 is blue. &14 is black.
  • Offset: &1063 and &1064 which define the first 2 colours of the palette "2nd" palette have been changed from &04 to &14. The "1st" and "2nd" palette are swapped between in BASIC to implement flashing colours. &04 is blue, &14 is black.

When the OS starts, the colours are set to black and code patched into the DOS/AMSDOS rom is executed.

BASIC patches

The BASIC ROM has been patched in the following way:

  • Offset &33 has been set to 0. It is the first character of " BASIC 1.1" text.

This stops the BASIC ROM from printing this text.

  • Offset &D7 has been set to 0. It is the first character of "Ready" text. This stops the BASIC ROM from printing this text.
  • At offset &af9, the code has been changed from:
LD HL,&ac8a

to

CALL &d583
  • Part of the text "Random number seed ?" at offset &1583 (&D583 in the CPU address space) has been patched with the following code:
ld hl,&ac8a
ld a,&aa
cp (hl)
ret nz
pop af
ld (hl),' '
scf
ret

When BASIC is started the sign on messages are not displayed, and it auto runs a command-line.

DOS/AMSDOS patches

The DOS/AMSDOS rom has been patched in the following way:

  • At offset &1c00 the following code has been added (on CPC this is filled with 0x0ff):
1c00 c314dc    jp      0dc14h
1c03 c35adc    jp      0dc5ah
;; this is the command to run
1c06:
defb &aa                               ;; command to autorun from basic
defb 'RUN"DISC',0
defb 'ST2',0
1c14 f3        di
1c15 c5        push    bc
1c16 d5        push    de
1c17 e5        push    hl
1c18 e5        push    hl
1c19 79        ld      a,c
1c1a e60f      and     0fh
1c1c 3d        dec     a
1c1d 82        add     a,d
1c1e 5f        ld      e,a
1c1f 2600      ld      h,00h
1c21 6a        ld      l,d
1c22 54        ld      d,h
1c23 29        add     hl,hl
1c24 29        add     hl,hl
1c25 29        add     hl,hl
1c26 19        add     hl,de
1c27 29        add     hl,hl
1c28 7d        ld      a,l
1c29 f6c0      or      0c0h
1c2b 57        ld      d,a
1c2c 1e00      ld      e,00h
1c2e 29        add     hl,hl
1c2f 29        add     hl,hl
1c30 7c        ld      a,h
1c31 d5        push    de
1c32 214edc    ld      hl,0dc4eh
1c35 1144be    ld      de,0be44h
1c38 010c00    ld      bc,000ch
1c3b edb0      ldir    
1c3d fe01      cp      01h
1c3f de7d      sbc     a,7dh
1c41 e1        pop     hl
1c42 d1        pop     de
1c43 06df      ld      b,0dfh
1c45 cd44be    call    0be44h
1c48 e1        pop     hl
1c49 d1        pop     de
1c4a c1        pop     bc
1c4b 37        scf     
1c4c fb        ei      
1c4d c9        ret       
1c4e ed79      out     (c),a
1c50 0602      ld      b,02h
1c52 edb0      ldir    
1c54 0107df    ld      bc,0df07h			;; select disc rom
1c57 ed49      out     (c),c
1c59 c9        ret     
1c5a cd96dc    call    0dc96h				;; unlock plus features
1c5d 01b87f    ld      bc,7fb8h  ;; page in plus registers
1c60 ed49      out     (c),c
1c62 2106dc    ld      hl,0dc06h
1c65 118aac    ld      de,0ac8ah ;; setup command for basic.
1c68 010e00    ld      bc,000eh
1c6b edb0      ldir    
1c6d 21b5dc    ld      hl,0dcb5h			;; palette
1c70 112264    ld      de,6422h                        ;; plus sprite palette
1c73 0e08      ld      c,08h
1c75 edb0      ldir    
1c77 110040    ld      de,4000h                        ;; plus sprite ram
unpack pixels into sprite ram
1c7a 7e        ld      a,(hl)
1c7b 0f        rrca    
1c7c 0f        rrca    
1c7d 0f        rrca    
1c7e 0f        rrca    
1c7f 12        ld      (de),a
1c80 1c        inc     e
1c81 eda0      ldi     
1c83 03        inc     bc
1c84 10f4      djnz    1c7ah
1c86 1660      ld      d,60h                           ;; plus sprite coordinates
1c88 0e0d      ld      c,0dh
1c8a edb0      ldir 
1c8c 01a07f    ld      bc,7fa0h              ;; page out plus registers
1c8f ed49      out     (c),c
;; lock plus
1c91 0110bc    ld      bc,0bc10h
1c94 1803      jr      1c99h
1c96 0111bc    ld      bc,0bc11h
1c99 21a4dc    ld      hl,0dca4h		;; plus unlock sequence
1c9c 7e        ld      a,(hl)
1c9d ed79      out     (c),a
1c9f 23        inc     hl
1ca0 0d        dec     c
1ca1 20f9      jr      nz,1c9ch
1ca3 c9        ret       
;; plus unlock sequence
1ca4 
defb &ff,&00,&ff,&77,&b3,&51,&a8,&d4,&62,&39,&9c,&46,&2b,&15,&8a,&cd,&ee
1cb5:
defw &07
defw &0f
defw &077f
defw &0fff
sprite pixels
1cbd 

defb &1

&1cbe-&1dbc is 0

defs 254

1dbd 04        inc     b
1dbe 00        nop     
1dbf 010009    ld      bc,0900h
1dc2 00        nop     
1dc3 00        nop     
1dc4 00        nop     
1dc5 24        inc     h
1dc6 00        nop     
1dc7 010009    ld      bc,0900h