At 01:01 PM 5/20/98 +0200, you wrote:
>I have to remove a bug in my program. And this is
>(maybe) exatcly about the thing you wrote above.
>
>What is illegal by reading the mapper-ports?
>If you dont have DOS2, how can you read/write them
>in a legal way without using the direct IN/OUT???
To avoid direct INs, you simply have to store the last value you sent to
the mapper port.
Example code:
map_write_FE:
out (#FE),a
ld (map_sav_FE),a
ret
map_sav_FE: db 1
map_read_FE:
ld a,(map_sav_FE)
ret
But in DOS2 this will still cause mayor problems when you load from disk,
because DOS2 will use it's own backup of the value sent to the mapper port,
which will not be correct if you do direct OUT.
The solution is to use the mapper BIOS functions, which are present in
DOS2. Note that MAP.COM ***doesn't*** fix the problem, it's a patch which
does direct IN and therefore will crash 1MB turbo R and other such machines.
Here is some code I wrote to correctly use a mapper under both DOS1 and
DOS2. I hope this helps you. If the problem remains, mail me with more
details.
For all other MSX mailinglist readers: please use this code if it helps you.
Note that these routines still do low-level access to the mapper. They
don't actually claim any segments from DOS2. So it only works if your
program is the only program in the system that uses the mapper. Also make
sure you don't use the two upper segments, because those are already in use
by DOS2 itself.
===================================================
EXTBIO: equ #FFCA
Mapper_Init:
xor a
ld d,4
ld e,2
call EXTBIO
or a
ret z
ld bc,#12
add hl,bc
ld (Mapper_WriteBios+1),hl
ld bc,#03
add hl,bc
ld (Mapper_ReadBios+1),hl
ld hl,Mapper_WriteDOS2
ld (Mapper_Write+1),hl
ld hl,Mapper_ReadDOS2
ld (Mapper_Read+1),hl
ret
; Write mapper
; ============
; In: b=page / c=port
Mapper_Write:
jp Mapper_WriteDOS1
Mapper_WriteDOS1:
;DOS1 - Self made mapper routine
ld hl,Mapper_CurPages-#FC
ld a,b
ld b,0
add hl,bc
ld (hl),a
out (c),a
ret
Mapper_WriteDOS2:
;DOS2 - The official way
ld a,c
rrca
rrca
ld h,a
ld a,b
Mapper_WriteBios:
jp 0
; Read mapper
; ===========
; In: c=port
; Out: b=page
Mapper_Read:
jp Mapper_ReadDOS1
Mapper_ReadDOS1:
;DOS1 - Self made mapper routine
ld hl,Mapper_CurPages-#FC
ld b,0
add hl,bc
ld b,(hl)
ret
Mapper_ReadDOS2:
ld a,c
rrca
rrca
ld h,a
Mapper_ReadBios:
call 0
ld b,a
ret
Mapper_CurPages: defb 3,2,1,0
===================================================
Bye,
Maarten
****
MSX Mailinglist. To unsubscribe, send an email to [EMAIL PROTECTED] and put
in the body (not subject) "unsubscribe msx [EMAIL PROTECTED]" (without the
quotes :-) Problems? contact [EMAIL PROTECTED] (www.stack.nl/~wiebe/mailinglist/)
****