llvm-mos-sdk
mapper.h
Go to the documentation of this file.
1 // Copyright 2022 LLVM-MOS Project
2 // Licensed under the Apache License, Version 2.0 with LLVM Exceptions.
3 // See https://github.com/llvm-mos/llvm-mos-sdk/blob/main/LICENSE for license
4 // information.
5 //
6 // Copyright 2019 Doug Fraker
7 // Copyright 2018 Christopher Parker
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 // SOFTWARE.
26 
27 #ifndef _MAPPER_H_
28 #define _MAPPER_H_
29 
30 #include <ines.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 
37 // Switch to another bank and call this function.
38 // Note: Using banked_call to call a second function from within
39 // another banked_call is safe.
40 __attribute__((leaf, callback(2))) void banked_call(char bank_id,
41  void (*method)(void));
42 
43 // Switch to the given bank (to $8000-bfff). Your prior bank is not saved.
44 // Can be used for reading data with a function in the fixed bank.
45 // bank_id: The bank to switch to.
46 __attribute__((leaf)) void set_prg_bank(char bank_id);
47 
48 // Get the current PRG bank at $8000-bfff.
49 // returns: The current bank.
50 __attribute__((leaf)) char get_prg_bank(void);
51 
52 // Set the current 8kb chr bank to the bank with this id.
53 // this will take effect immediately
54 // and automatically rewrite at the top of every frame
55 __attribute__((leaf)) void set_chr_bank(char bank_id);
56 
57 // Set the current 8kb chr bank to the bank with this id.
58 // this will take effect at the next frame
59 // and automatically rewrite at the top of every frame
60 __attribute__((leaf)) void swap_chr_bank(char bank_id);
61 
62 // Set the current 8kb chr bank to the bank with this id.
63 // this will take effect immediately, such as for mid screen changes
64 // but then will be overwritten by the set_chr_bank() value
65 // in the next frame.
66 __attribute__((leaf)) void split_chr_bank(char bank_id);
67 
68 // if you need to swap CHR banks mid screen, perhaps you need more
69 // than 256 unique tiles, first write (one time only) the CHR bank
70 // for the top of the screen with set_chr_bank().
71 // Then, every frame, time a mid screen split (probably with
72 // a sprite zero hit) and then change the CHR bank with
73 // split_chr_bank().
74 //
75 // example ---- in game loop
76 // split(0); ---- wait for sprite zero hit, set X scroll to 0
77 // split_chr_bank_0(6) ---- change CHR bank to #6
78 
79 #define MIRROR_LOWER_BANK 0
80 #define MIRROR_UPPER_BANK 1
81 #define MIRROR_VERTICAL 2
82 #define MIRROR_HORIZONTAL 3
83 
84 // Set the current mirroring mode. Your options are MIRROR_LOWER_BANK,
85 // MIRROR_UPPER_BANK, MIRROR_HORIZONTAL, and MIRROR_VERTICAL.
86 // LOWER and UPPER are single screen modes.
87 __attribute__((leaf)) void set_mirroring(char mirroring);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif // _MAPPER_H_
ines.h
method
void(* method)(void))
Definition: mapper.h:41
bank_id
char bank_id
Definition: mapper.h:97