This file is indexed.

/usr/share/z88dk/lib/sms_crt0.asm is in z88dk-data 1.8.ds1-10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
;       Startup Code for Sega Master System
;
;	Haroldo O. Pinheiro February 2006
;
;	$Id: sms_crt0.asm,v 1.2 2007/06/02 22:33:59 dom Exp $
;

	DEFC	ROM_Start  = $0000
	DEFC	INT_Start  = $0038
	DEFC	NMI_Start  = $0066
	DEFC	CODE_Start = $0100
	DEFC	RAM_Start  = $C000
	DEFC	RAM_Length = $2000
	DEFC	Stack_Top  = $dff0

	MODULE  sms_crt0

;-------
; Include zcc_opt.def to find out information about us
;-------

	INCLUDE "zcc_opt.def"

;-------
; Some general scope declarations
;-------

        XREF    _main           ;main() is always external to crt0 code
        XDEF    cleanup         ;jp'd to by exit()
        XDEF    l_dcal          ;jp(hl)

        XDEF    _std_seed       ;Integer rand() seed

        XDEF    exitsp          ;Pointer to atexit() stack
        XDEF    exitcount       ;Number of atexit() functions registered

        XDEF    __sgoioblk      ;std* control block

        XDEF    heaplast        ;Near malloc heap variables
        XDEF    heapblocks      ;

        XDEF    _vfprintf       ;jp to printf() core routine
        
        XDEF	fputc_vdp_offs	;Current character pointer
        
	XDEF	aPLibMemory_bits;apLib support variable
	XDEF	aPLibMemory_byte;apLib support variable
	XDEF	aPLibMemory_LWM	;apLib support variable
	XDEF	aPLibMemory_R0	;apLib support variable

	XDEF	raster_procs	;Raster interrupt handlers
	XDEF	pause_procs	;Pause interrupt handlers
	
	XDEF	timer		;This is incremented every time a VBL/HBL interrupt happens
	XDEF	_pause_flag	;This alternates between 0 and 1 every time pause is pressed

	org    ROM_Start

	jp	start
	
	defm    "Sega Master System"
	
;-------        
; Interrupt handlers
;-------
.filler1
	defs	(INT_Start - filler1)
.int_RASTER	
	push	hl
	
	ld	a, ($BF)
	or	a
	jp	p, int_not_VBL	; Bit 7 not set
	jr	int_VBL

.int_not_VBL	
	pop	hl
	reti
	
.int_VBL	
	ld	hl, timer
	ld	a, (hl)
	inc	a
	ld	(hl), a
	inc	hl
	ld	a, (hl)
	adc	a, 1
	ld	(hl), a		;Increments the timer
	
	ld	hl, raster_procs
	jr	int_handler

.filler2
	defs	(NMI_Start - filler2)
.int_PAUSE
	push	hl
	
	ld	hl, _pause_flag
	ld	a, (hl)
	xor	a, 1
	ld	(hl), a
	
	ld	hl, pause_procs
	jr	int_handler	

.int_handler
	push	af
	push	bc
	push	de
.int_loop
	ld	a, (hl)
	inc	hl
	or	(hl)
	jr	z, int_done
	push	hl
	ld	a, (hl)
	dec	hl
	ld	l, (hl)
	ld	h, a
	call	call_int_handler
	pop	hl
	inc	hl
	jr	int_loop
.int_done
	pop	de
	pop	bc
	pop	af
	pop	hl
	
	ei

	reti

.call_int_handler
	jp	(hl)

;-------        
; Beginning of the actual code
;-------
.filler3
	defs   (CODE_Start - filler3)

.start
; Make room for the atexit() stack
	ld	hl,Stack_Top-64
	ld	sp,hl
; Clear static memory
	ld	hl,RAM_Start
	ld	de,RAM_Start+1
	ld	bc,RAM_Length-1
	ld	(hl),0
	ldir
	ld      (exitsp),sp

IF !DEFINED_nostreams
IF DEFINED_ANSIstdio
; Set up the std* stuff so we can be called again
	ld	hl,__sgoioblk+2
	ld	(hl),19	;stdin
	ld	hl,__sgoioblk+6
	ld	(hl),21	;stdout
	ld	hl,__sgoioblk+10
	ld	(hl),21	;stderr
ENDIF
ENDIF

	ld      hl,$8080
	ld      (fp_seed),hl
	xor     a
	ld      (exitcount),a
	
	call	DefaultInitialiseVDP
	
	im	1
	ei

; Entry to the user code
	call    _main

.cleanup
;
;       Deallocate memory which has been allocated here!
;
	push	hl
IF !DEFINED_nostreams
IF DEFINED_ANSIstdio
	LIB	closeall
	call	closeall
ENDIF
ENDIF

.endloop
	jr	endloop
.l_dcal
	jp      (hl)
	
;---------------------------------
; VDP Initialization
;---------------------------------
.DefaultInitialiseVDP
    push hl
    push bc
        ld hl,_Data
        ld b,_End-_Data
        ld c,$bf
        otir
    pop bc
    pop hl
    ret

    DEFC SpriteSet          = 0       ; 0 for sprites to use tiles 0-255, 1 for 256+
    DEFC NameTableAddress   = $3800   ; must be a multiple of $800; usually $3800; fills $700 bytes (unstretched)
    DEFC SpriteTableAddress = $3f00   ; must be a multiple of $100; usually $3f00; fills $100 bytes

_Data:
    defb @00000100,$80
    ;     |||||||`- Disable synch
    ;     ||||||`-- Enable extra height modes
    ;     |||||`--- SMS mode instead of SG
    ;     ||||`---- Shift sprites left 8 pixels
    ;     |||`----- Enable line interrupts
    ;     ||`------ Blank leftmost column for scrolling
    ;     |`------- Fix top 2 rows during horizontal scrolling
    ;     `-------- Fix right 8 columns during vertical scrolling
    defb @10000100,$81
    ;      |||| |`- Zoomed sprites -> 16x16 pixels
    ;      |||| `-- Doubled sprites -> 2 tiles per sprite, 8x16
    ;      |||`---- 30 row/240 line mode
    ;      ||`----- 28 row/224 line mode
    ;      |`------ Enable VBlank interrupts
    ;      `------- Enable display
    defb (NameTableAddress/2^10) |@11110001,$82
    defb (SpriteTableAddress/2^7)|@10000001,$85
    defb (SpriteSet/2^2)         |@11111011,$86
    defb $f|$f0,$87
    ;     `-------- Border palette colour (sprite palette)
    defb $00,$88
    ;     ``------- Horizontal scroll
    defb $00,$89
    ;     ``------- Vertical scroll
    defb $ff,$8a
    ;     ``------- Line interrupt spacing ($ff to disable)
_End:
	

;---------------------------------
; Select which printf core we want
;---------------------------------
._vfprintf
IF DEFINED_floatstdio
	LIB	vfprintf_fp
	jp	vfprintf_fp
ELSE
	IF DEFINED_complexstdio
		LIB	vfprintf_comp
		jp	vfprintf_comp
	ELSE
		IF DEFINED_ministdio
			LIB	vfprintf_mini
			jp	vfprintf_mini
		ENDIF
	ENDIF
ENDIF

; Static variables kept in safe workspace

DEFVARS RAM_Start
{
__sgoioblk      	ds.b    40      ;stdio control block
_std_seed        	ds.w    1       ;Integer seed
exitsp          	ds.w    1       ;atexit() stack
exitcount       	ds.b    1       ;Number of atexit() routines
fp_seed         	ds.w    3       ;Floating point seed (not used ATM)
extra           	ds.w    3       ;Floating point spare register
fa              	ds.w    3       ;Floating point accumulator
fasign          	ds.b    1       ;Floating point variable
heapblocks      	ds.w    1       ;Number of free blocks
heaplast        	ds.w    1       ;Pointer to linked blocks
fputc_vdp_offs		ds.w	1	;Current character pointer
aPLibMemory_bits	ds.b	1	;apLib support variable
aPLibMemory_byte	ds.b	1	;apLib support variable
aPLibMemory_LWM		ds.b	1	;apLib support variable
aPLibMemory_R0		ds.w	1	;apLib support variable
raster_procs		ds.w	8	;Raster interrupt handlers
pause_procs		ds.w	8	;Pause interrupt handlers
timer			ds.w	1	;This is incremented every time a VBL/HBL interrupt happens
_pause_flag		ds.b	1	;This alternates between 0 and 1 every time pause is pressed
}


;--------
; Now, include the math routines if needed..
;--------
IF NEED_floatpack
;        INCLUDE "#float.asm"
ENDIF