6139befc20f07c62bf8d1022f5fa24e5031d4da0
[reactos.git] / reactos / boot / freeldr / freeldr / video / bank.c
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <freeldr.h>
21 #include <video.h>
22 #include <comm.h>
23 #include <rtl.h>
24 #include <debug.h>
25 #include <machine.h>
26
27
28 #if 0 /* This stuff isn't used and as far as I'm concerned it can go - GvG */
29 U32 CurrentMemoryBank = 0;
30
31 VOID VideoSetMemoryBank(U16 BankNumber)
32 {
33 if (CurrentMemoryBank != BankNumber)
34 {
35 BiosVesaSetBank(BankNumber);
36 CurrentMemoryBank = BankNumber;
37 }
38 }
39
40 U32 VideoGetMemoryBankForPixel(U32 X, U32 Y)
41 {
42 U32 Bank;
43 U32 MemoryPos;
44 U32 BankSize;
45 U32 BytesPerPixel;
46
47 //BytesPerPixel = ROUND_UP(VesaVideoModeInformation.BitsPerPixel, 8) / 8;
48 BytesPerPixel = (VesaVideoModeInformation.BitsPerPixel + 7) >> 3;
49 MemoryPos = (Y * VideoGetBytesPerScanLine()) + (X * BytesPerPixel);
50 //BankSize = VesaVideoModeInformation.WindowGranularity * 1024;
51 BankSize = VesaVideoModeInformation.WindowGranularity << 10;
52 Bank = MemoryPos / BankSize;
53
54 return Bank;
55 }
56
57 U32 VideoGetMemoryBankForPixel16(U32 X, U32 Y)
58 {
59 U32 Bank;
60 U32 MemoryPos;
61 U32 BankSize;
62
63 MemoryPos = (Y * VideoGetBytesPerScanLine()) + (X / 2);
64 //BankSize = VesaVideoModeInformation.WindowGranularity * 1024;
65 BankSize = VesaVideoModeInformation.WindowGranularity << 10;
66 Bank = MemoryPos / BankSize;
67
68 return Bank;
69 }
70
71 U32 VideoGetBankOffsetForPixel(U32 X, U32 Y)
72 {
73 U32 BankOffset;
74 U32 MemoryPos;
75 U32 BankSize;
76 U32 BytesPerPixel;
77
78 //BytesPerPixel = ROUND_UP(VesaVideoModeInformation.BitsPerPixel, 8) / 8;
79 BytesPerPixel = (VesaVideoModeInformation.BitsPerPixel + 7) >> 3;
80 MemoryPos = (Y * VideoGetBytesPerScanLine()) + (X * BytesPerPixel);
81 //BankSize = VesaVideoModeInformation.WindowGranularity * 1024;
82 BankSize = VesaVideoModeInformation.WindowGranularity << 10;
83 BankOffset = MemoryPos % BankSize;
84
85 return BankOffset;
86 }
87
88 U32 VideoGetBankOffsetForPixel16(U32 X, U32 Y)
89 {
90 U32 BankOffset;
91 U32 MemoryPos;
92 U32 BankSize;
93
94 MemoryPos = (Y * VideoGetBytesPerScanLine()) + (X / 2);
95 //BankSize = VesaVideoModeInformation.WindowGranularity * 1024;
96 BankSize = VesaVideoModeInformation.WindowGranularity << 10;
97 BankOffset = MemoryPos % BankSize;
98
99 return BankOffset;
100 }
101
102 U32 VideoGetOffScreenMemoryOffsetForPixel(U32 X, U32 Y)
103 {
104 U32 MemoryPos;
105 U32 BytesPerPixel;
106
107 //BytesPerPixel = ROUND_UP(VesaVideoModeInformation.BitsPerPixel, 8) / 8;
108 BytesPerPixel = (VesaVideoModeInformation.BitsPerPixel + 7) >> 3;
109 MemoryPos = (Y * VesaVideoModeInformation.BytesPerScanLine) + (X * BytesPerPixel);
110
111 return MemoryPos;
112 }
113 #endif
114
115 VOID VideoCopyOffScreenBufferToVRAM(VOID)
116 {
117 MachVideoCopyOffScreenBufferToVRAM(VideoOffScreenBuffer);
118 }