Durante a adaptação do Typhoon 128 para o Beta 48, eu criei uma rotina de carregamento de setores do disquete para a memória. Diferente da rotina da ROM do Beta 48 que denomino R_B_SECTS (12010 para CAS e 11990 para CBI), não faz uso de nenhum dos 112 bytes das variáveis de sistema do TRDOS, nem da área de buffer de impressora. Fazendo um assembly do jeito que está na listagem, a rotina ocupa 67 bytes, mas obviamente irá demandar mais memória para carregar alguma coisa efetiva dentro de um programa.
Há duas versões de ROM existentes, de um lado da interface original Beta 48 e da CAS, e de outro, da CBI-95 e seus derivados (IDS e Arcade). Portanto se deve montar dois códigos de máquinas diferentes, um para cada versão. Felizmente coloquei tais diferenças nos arquivos header e, assim, a listagem de ambas as versões são quase idênticas.
;
;===============================================================================
; File: ReadSectors_CBI.asm
; Version: 1.1
; Date: Jun/20/2012
; Author: Flavio Matsumoto (reikainosuke-tk@yahoo.com.br)
; Description:
; Routine for Beta 48 disc interface (CBI-95 version). Read B sectors from
; disc, starting from sector E of track D. The sectors are written to memory,
; starting from address pointed by HL. Beta 48 routine R_B_SECTS do the same
; thing, but this routine does not use any TRDOS system variable. Beta 48
; ROM must be enabled before calling this routine.
; License:
; This program is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program. If not, see <http://www.gnu.org/licenses/>.
;===============================================================================
;
Include "Header_Beta48_CBI.asm"
;
ReadSec0:
BIT 4,E ; Jump forward if maximum sector value (16) was
JR Z,ReadSec2 ;not reached (keep head on the same track).
LD E,0 ; Reset current sector value and increment
INC D ;track value to the next position.
; Main entry point.
ReadSec:
; The drive head is positioned on required physical track of disk. Register E
;contains logical track ID number. Only for single side disk the physical track
;is same as logical track. In double side disk, the physical track is logical
;track divided by 2; the remainder is the ID number of disk side (0 or 1).
XOR A ; Enable Beta 48 IO ports. Bits D0-D2 define
OUT (252),A ;screen border color. If another color is
;desired, replace 'XOR A' with 'LD A,<color>'.
LD C,D ; Store track number in C.
LD A,(CurDrv) ; Take the current drive unity number, raise
OR 111100 ;bit 4 (i.e. select side 0 of disc) and send
OUT (255),A ;to register of Beta 48 interface.
LD A,(DiskSides) ; Get number of disk sides.
AND A ; Jump forward if it is single sided. The side
JR Z,ReadSec1 ;0 is already selected.
SRL C ; Calculate physical track number.
JR NC,ReadSec1 ; Jump forward if logical track number was
LD A,(CurDrv) ;even (side 0 of disc is already selected),
;but select side 1 if it was odd.
AND %01101111 ; Take the current drive ID number, lower bit 4
OUT (255),A ;(i.e. select side 1) and send to register.
ReadSec1:
LD A,C ; Recover physical track number and position
CALL NMI_SEEKA ;head there.
CALL DELAY ; Extra delay time.
ReadSec2:
PUSH BC ; Save registers before subroutine call.
PUSH DE
CALL NMI_RDSEC ; Read 256 bytes (1 sector) from disc.
POP DE ; Restore registers to previous values.
POP BC
INC H ; Update memory pointer to next position (256
;bytes or 1 sector ahead).
INC E ; Update sector number to next position.
DJNZ ReadSec0 ; Repeat until all B sectors were read.
LD A,(CurDrv) ; Switch back to TK90X ROM.
OR %10111100
OUT (255),A
LD A,128 ; Enable Beta 48 IO ports. Bits D0-D2 define
OUT (252),A ;screen border color. If another color is
;desired, use 'LD A,128+<color>'.
RET
;
; Program variables
;-------------------
; The lower 2 bits of CurDrv specify drive to be selected (00=A, 01=B, 10=C and
;11=D). It is recommended to initialize this value with TRDOS system variable
;STAT255 after lowering its D7 bit.
CurDrv:
DEFS 1 ; D7=0 (Beta ROM enabled), D6=0 (MFM), D5=1
;(printer strobe off), D4 (select side), D3=D2=1 and
;D1&D0 select drive.
; DiskSides specify number of disk sides.
DiskSides:
DEFB 1 ; 0 for single side disk, 1 for double side.
;
End
Não é necessário digitar a listagem acima, ambas as versões (CBI e CAS) estão disponíveis no Google Drive.
Nenhum comentário:
Postar um comentário
Seu comentário é bem vindo, mas peço que use este espaço adequadamente.