/[projet1]/public/oric/demos/OricTech/code/sector_1-jasmin.asm
Defence Force logotype

Contents of /public/oric/demos/OricTech/code/sector_1-jasmin.asm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1397 - (show annotations)
Sun Apr 9 10:42:35 2017 UTC (2 years, 11 months ago) by dbug
File size: 4137 byte(s)
Updated the OricTech project to use the new version of the FloppyBuilder
1 ;
2 ; This is the bootsector for the Jasmin drives.
3 ; No particular magic to do here, all the versions of the Jasmin system load the boot sector in page 4,
4 ; so we can just assemble the bootsector code using $400 as the base address
5 ;
6 ; Warning: This whole code CANNOT be more than 256 bytes (ie: the size of the sector)
7
8 #define FDC_command_register $03f4
9 #define FDC_status_register $03f4
10 #define FDC_track_register $03f5
11 #define FDC_sector_register $03f6
12 #define FDC_data $03f7
13 #define FDC_flags $03f8
14 #define FDC_drq $03FC
15
16 #define FDC_ovl_control $03FA
17 #define FDC_rom_control $03FB
18
19 #define CMD_ReadSector $8c
20 #define CMD_Seek $1F
21
22 #define wait_status_floppy 30
23
24 #include "floppy_description.h" ; This file is generated by the floppy builder
25
26 .zero
27
28 *=$00
29
30 retry_counter .dsb 1 ; Number of attempts at loading data (ie: not quite clear what happens when this fails...)
31
32 .text
33
34 *=$400
35
36 jmp JasminStart ;.byt $01,$00,$00
37 .byt $00,$00,$00,$00,$00,$20,$20,$20,$20,$20,$20,$20,$20
38 .byt $00,$00,$03,$00,$00,$00,$01,$00,$53,$45,$44,$4F,$52,$49,$43,$20
39 .byt $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
40 .byt $20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20,$20
41
42 JasminStart
43 ;jmp JasminStart
44 ;
45 ; Here starts the actual executable part, maximum available size is 233 bytes (256-23)
46 ;
47
48 ;
49 ; Try to find the load address
50 ;
51 sei ; Disable interruptions
52
53 ; Enable Overlay ram
54 lda #1
55 sta FDC_ovl_control ; Enable Overlay
56 lda #1
57 sta FDC_rom_control ; Disable ROM
58
59
60 ;
61 ; Read sector data
62 ;
63 ldy #4
64 sty retry_counter
65 read_sectors_loop
66
67 readretryloop
68 nop
69 nop
70 nop
71
72 read_one_sector
73 ;
74 ; Check if we are on the correct track already and if not
75 ; then send a SEEK command to the FDC to move the head to
76 ; the correct track.
77 ;
78 ldx #FLOPPY_LOADER_TRACK
79 cpx FDC_track_register
80 beq track_ok
81
82 ; Write the track number in the FDC data register
83 stx FDC_data
84
85 wait_drive2
86 lda FDC_drq ; We are waiting for the drive maybe not useful if drive is ready after the eprom boot
87 bmi wait_drive2
88
89 ;
90 ; Send a SEEK command (change track)
91 ;
92 lda #CMD_Seek
93 sta FDC_command_register
94 ;
95 ; Command words should only be loaded in the Command Register when the Busy status bit is off (Status bit 0). The one exception is the Force Interrupt command.
96 ; Whenever a command is being executed, the Busy status bit is set.
97 ; When a command is completed, an interrupt is generated and the busy status bit is reset.
98 ; The Status Register indicates whethter the completed command encountered an error or was fault free. For ease of discussion, commands are divided into four types (I, II, III, IV).
99 ldy #4
100 r_wait_completion
101 dey
102 bne r_wait_completion
103 r2_wait_completion
104 lda FDC_status_register
105 lsr
106 bcs r2_wait_completion
107 asl
108
109 track_ok
110
111 ; Write the sector number in the FDC sector register
112 __auto__sector_index
113 lda #FLOPPY_LOADER_SECTOR
114 sta FDC_sector_register
115
116
117 ;
118 ; Send a READSECTOR command
119 ;
120 lda #CMD_ReadSector
121 sta FDC_command_register
122
123 ldy #wait_status_floppy
124 waitcommand
125 nop ; Not useful but for old Floppy drive maybe
126 nop ; Not useful but for old Floppy drive maybe
127 dey
128 bne waitcommand
129
130 ;
131 ; Read the sector data
132 ;
133 ldy #0
134 fetch_bytes_from_FDC
135 lda FDC_drq
136 bmi fetch_bytes_from_FDC
137 lda FDC_data
138 __auto_write_address
139 sta FLOPPY_LOADER_ADDRESS,y
140
141 iny
142 bne fetch_bytes_from_FDC
143 ; Done loading the sector
144
145 lda FDC_status_register
146 and #$1C
147
148 beq sector_OK
149 dec retry_counter
150 bne readretryloop
151
152 sector_OK
153 inc __auto__sector_index+1
154 inc __auto_write_address+2
155 dec sector_counter
156 bne read_sectors_loop
157
158 ;
159 ; Data successfully loader (we hope)
160 ;
161 sei
162 lda #%10000001 ; Disable the FDC (Eprom select + FDC Interrupt request)
163 sta FDC_flags
164
165 ldx #1 ; 1 = Jasmin initialisation code
166 jmp FLOPPY_LOADER_ADDRESS
167
168 sector_counter .byt (($FFFF-FLOPPY_LOADER_ADDRESS)+1)/256
169
170 _END_
171

  ViewVC Help
Powered by ViewVC 1.1.26