summaryrefslogtreecommitdiff
path: root/src/setpcbase.s
blob: 6f965ae557b886ec05fc3c72396d79b35462aa55 (plain)
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
asm_S9xSetPCBase:
	.file 1 "os9x_asm_cpu.cpp"
	.loc 1 16 0
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0


	MOV		R1,R0,LSR #MEMMAP_SHIFT
	@ MEMMAP_SHIFT is 12, Address is 0xFFFFFFFF at max, so
	@ R1 is maxed by 0x000FFFFF, MEMMAP_MASK is 0x1000-1=0xFFF
	@ so AND MEMMAP_MASK is BIC 0xFF000
	BIC		R1,R1,#0xFF000
	bic	r0, r0, #0xff0000

	@ R2 <= Map[block] (GetAddress)
	LDR		R2,[reg_cpu_var,#Map_ofs]

	LDR		R2,[R2,R1,LSL #2]
	CMP		R2,#MAP_LAST
	BLO		SPCSpecial  @ special

	mov	regpcbase, r2
	add	rpc, r2, r0
	str	rpc, [reg_cpu_var, #PC_ofs]
	str	regpcbase, [reg_cpu_var, #PCBase_ofs]

	bx	r3
	

SPCSpecial:

	LDR		PC,[PC,R2,LSL #2]
	MOV		R0,R0 		@ nop, for align

	.long	SPC_PPU
	.long	SPCDefault
	.long	SPCDefault
	.long	SPCDefault
	.long	SPCDefault
	.long	SPCDefault
	.long	SPCDefault
	.long	SPCDefault
	.long	SPCDefault
	.long	SPCDefault
	.long	SPCDefault
	.long	SPCDefault
/*
	MAP_PPU 	0
	MAP_CPU 	1
	MAP_DSP 	2
	MAP_LOROM_SRAM	3
	MAP_HIROM_SRAM	4
	MAP_NONE	5
	MAP_DEBUG	6	
	MAP_C4		7
	MAP_BWRAM	8
	MAP_BWRAM_BITMAP	9
	MAP_BWRAM_BITMAP2	10
	MAP_SA1RAM	11
	MAP_LAST	12
*/

vMemory:
	.word	Memory
.equ	_fillram, 20

SPC_PPU:
	@CPU.PCBase = Memory.FillRAM - 0x2000;
	@CPU.PC = CPU.PCBase + (Address & 0xffff);

	ldr	r1, vMemory
	ldr	r2, [r1, #_fillram]
	sub	r2, r2, #0x2000

	mov	regpcbase, r2
	add	rpc, r2, r0
	str	rpc, [reg_cpu_var, #PC_ofs]
	str	regpcbase, [reg_cpu_var, #PCBase_ofs]
	
	@return;
	bx 	r3
	@-------------------

SPCDefault:
	bx	r3