convert line ends
[canaan.git] / prj / tech / libsrc / dev2d / bank.h
blob83e784a0f80c6806eb2df0620f53b705a4c38efc
1 /*
2 * $Source: s:/prj/tech/libsrc/dev2d/RCS/bank.h $
3 * $Revision: 1.1 $
4 * $Author: KEVIN $
5 * $Date: 1996/04/10 16:41:23 $
7 * Declarations for bank-switching. Lots of gruesome stuff
8 * to make things efficient, but still allow drawing in interrupt.
10 * This file is part of the dev2d library.
14 #ifndef __BANK_H
15 #define __BANK_H
17 #include <grd.h>
18 #include <idevice.h>
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
24 extern volatile int gdd_bank;
25 extern volatile int gdd_ignore_bank;
26 extern volatile int gdd_save_bank;
28 // a pointer to the function that actually sets the bank
29 #define gd_force_bank \
30 ((void (*)(int bank))grd_device_table[GDC_SET_BANK])
32 // gd_inc_bank sets the semaphore to indicate gdd_bank is unreliable,
33 // increments and sets the bank, and resets the unreliability semaphore.
34 #define gd_inc_bank() \
35 do { \
36 gdd_ignore_bank++; \
37 gd_force_bank(++gdd_bank); \
38 gdd_ignore_bank--; \
39 } while (0)
41 // gd_set_bank sets a semaphore to indicate that the bank must be
42 // restored by any primitive subsequently called (in interrupt,
43 // generally).
44 // use exactly once per primitive. always use gd_restore_bank
45 // before exiting.
47 #define gd_set_bank(b) \
48 do { \
49 gdd_save_bank++; \
50 if (gdd_ignore_bank!=0) { \
51 gdd_bank = b; \
52 gd_force_bank(b); \
53 break; \
54 } \
55 if (gdd_bank != b) { \
56 gdd_ignore_bank++; \
57 gdd_bank = b; \
58 gd_force_bank(b); \
59 gdd_ignore_bank--; \
60 } \
61 } while (0)
63 // gd_restore_bank decrements the save semaphore and resets
64 // the bank when necessary.
66 #define gd_restore_bank(sb) \
67 do { \
68 gdd_save_bank--; \
69 if ((gdd_save_bank!=0)&& \
70 (sb!=gdd_bank)) { \
71 gdd_bank = sb; \
72 gd_force_bank(gdd_bank); \
73 } \
74 } while (0)
76 /* calculates a video memory pointer from offset p. */
77 #define gd_bank_p(p) \
78 ((uchar *) grd_cap->vbase+((p)&0xffff))
80 #ifdef __cplusplus
82 #endif
83 #endif /* !__BANK_H */