RAM used / corrupted by +3DOS

2»

Comments

  • BCHBCH
    edited January 2013
    Hi,

    I've worked a disk version of RTYPE. It works fine in the +3/+3e from floppy or IDE device. I thought this was a good thread to share it. The routine is very simple; it loads each level from the storage device when need it. The problem was to find a place to relocate the stack under 49120 while loading. Off course the screen memory was an option but I wanted the modification to be as transparent as possible. These are the two patches to the original RTYPE code:
    org 36639
    
    bankm		EQU 23388
    DOS_EST_1346 	equ $13F
    DOS_OPEN 		equ $106
    DOS_READ 		equ $112
    DOS_CLOSE		equ $109
    DOS_MOTOR_OFF	equ $19c
    
    
    start				 
    
    	ld a,7			;36639
    	call paging
    		
    	ld hl, 24000		;backup 200 bytes data 
    	ld de, 49152
    	ld bc, 200
    	ldir
    		
    	LD (24198), SP		;save stack           
            LD SP, 24197            ;move stack 
    
            ld hl, 0
            ld de, 0
            call DOS_EST_1346	; kill ramdisk-cache
            
    open_file
    
    	LD HL, filename	        ; file name at 36766
            LD DE, 2                ; E=2 open mode
            LD BC, 5                ; C=5 shared read mode
            CALL DOS_OPEN           ; DOS OPEN           
            
    read_fileLenght
    
    	LD HL, 16		; set position after first 16 bytes
    	LD E, 0
    	LD B, 0			; file 0
    	call 310		; DOS SET POSITION
            
            LD HL, 24592            ; target addr 
            LD DE, 2             	; block lenght
            LD BC, 0		; file 1, page 0
            CALL DOS_READ           ; 
    
    	LD HL, 128		; set position after header
    	LD E, 0
    	LD B, 0			; file 0
    	call 310		; DOS SET POSITION
    
    	LD HL, 50350
    	ld de, (24592)
    	ld BC, 0
    	call DOS_READ
    			
    	ld	b, 0		; Close file 0
    	call DOS_CLOSE		; DOS CLOSE
    	call DOS_MOTOR_OFF 
    		
    	LD SP, (24198)		;recover stack
    		
    	ld hl, 49152		;restore 200 bytes data
    	ld de, 24000
    	ld bc, 200
    	ldir
    		
    	ld a, 16
    	call paging
    		
    	ret
    
    paging
    		
    	ld bc, 32765
    	out (c),a		; execute paging
    	ld (bankm),a		; 
    	ret
    		
    filename:		defm "RTYPEL1.LEV", 255
    

    org 65115
    
    		
    	CALL 49861              ;65115
            LD HL, 29114            ;65118
            LD C, 5                 ;65121
            CALL 49279              ;65123
            INC C                   ;65126
            LD HL, 29071            ;65127
            CALL 49281              ;65130
                        
            
            LD A, (29084)           ;read level nr 
            LD (36772), A		;poke level nr to "filename"
            ld a, 16
    	ld (23388), a		;init BANKM
    	ld a, 4
    	ld (23399), a		;init BANK67
    	LD (23385), SP          ;save stack
            LD SP, 23384		;move stack
            DI
            CALL 36639              ;call loading routine
            EI
            ld sp, (23385)		;restore stack
    	nop
    	nop
    	nop
    	nop
    	nop
    	nop
    	xor A			;original code...
    

    The levels must be named RTYPEL1.LEV, RTYPEL2.LEV and so on till level 8...

    Greets!
Sign In or Register to comment.