File tree Expand file tree Collapse file tree 6 files changed +83
-37
lines changed Expand file tree Collapse file tree 6 files changed +83
-37
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,19 @@ vga_irq.obj: vga_irq.cpp vga_irq.hpp vga_reg.lib pc_pit.lib pc_cpu.lib
48
48
vga_irq.lib : vga_irq.obj vga_reg.lib pc_pit.lib pc_cpu.lib
49
49
$(LIB ) $@ $<
50
50
51
- vga_mode.obj : vga_mode.cpp vga_mode.hpp vga_reg.lib pc_bus.lib pc_cpu.lib
51
+ vga_mode.obj : vga_mode.cpp vga_mode.hpp vga_reg.lib vga_bios.lib pc_bus.lib pc_cpu.lib
52
52
$(CPP ) $[@
53
- vga_mode.lib : vga_mode.obj vga_reg.lib pc_bus.lib pc_cpu.lib
53
+ vga_mode.lib : vga_mode.obj vga_reg.lib vga_bios.lib pc_bus.lib pc_cpu.lib
54
54
$(LIB ) $@ $<
55
55
56
- vga_reg.obj : vga_reg.cpp vga_reg.hpp pc_bus.lib
56
+ vga_reg.obj : vga_reg.cpp vga_reg.hpp pc_bus.lib pc_cpu.lib
57
57
$(CPP ) $[@
58
- vga_reg.lib : vga_reg.obj pc_bus.lib
58
+ vga_reg.lib : vga_reg.obj pc_bus.lib pc_cpu.lib
59
+ $(LIB ) $@ $<
60
+
61
+ vga_bios.obj : vga_bios.cpp vga_bios.hpp pc_bus.lib
62
+ $(CPP ) $[@
63
+ vga_bios.lib : vga_bios.obj pc_bus.lib
59
64
$(LIB ) $@ $<
60
65
61
66
sb16.obj : sb16.cpp sb16.hpp pc_dma.lib pc_pic.lib pc_cpu.lib pc_bus.lib
Original file line number Diff line number Diff line change
1
+ #include " vga_bios.hpp"
2
+
3
+ #include < cstdint>
4
+
5
+ #include " i86.h" // int386
6
+
7
+ using std::uint8_t ;
8
+
9
+ namespace rqdq {
10
+ namespace vga {
11
+
12
+ namespace bios {
13
+
14
+ void SetMode (uint8_t modeNum) {
15
+ union REGS r;
16
+ r.h .ah = 0 ; // set video mode
17
+ r.h .al = modeNum;
18
+ int386 (0x10 , &r, &r); }
19
+
20
+
21
+ std::uint8_t GetMode () {
22
+ union REGS r;
23
+ r.h .ah = 0x0f ; // get current video mode
24
+ int386 (0x10 , &r, &r);
25
+ return r.h .al ; }
26
+
27
+
28
+ } // namespace bios
29
+
30
+
31
+ } // namespace vga
32
+ } // namespace rqdq
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+ #include < cstdint>
3
+
4
+ namespace rqdq {
5
+ namespace vga {
6
+
7
+ namespace bios {
8
+
9
+ void SetMode (std::uint8_t modeNum);
10
+
11
+ std::uint8_t GetMode ();
12
+
13
+
14
+ } // namespace bios
15
+
16
+
17
+ } // namespace vga
18
+ } // namespace rqdq
Original file line number Diff line number Diff line change 1
1
#include " vga_mode.hpp"
2
2
3
- #include < i86.h> // int386
4
-
5
3
#include " pc_bus.hpp"
6
4
#include " pc_cpu.hpp"
5
+ #include " vga_bios.hpp"
7
6
#include " vga_reg.hpp"
8
7
9
8
namespace rqdq {
10
9
namespace vga {
11
10
12
-
13
- void SetBIOSMode (int num) {
14
- union REGS r;
15
- r.x .eax = num;
16
- int386 (0x10 , &r, &r); }
17
-
18
-
19
- class SequencerDisabledSection {
20
- public:
21
- SequencerDisabledSection (const pc::CriticalSection& cs) :cs(cs) {
22
- pc::TXdw (VP_SEQC, 0x100 ); } // clear bit 1, starting reset
23
- ~SequencerDisabledSection () {
24
- pc::TXdw (VP_SEQC, 0x300 ); } // undo reset / restart sequencer)
25
- private:
26
- SequencerDisabledSection& operator =(const SequencerDisabledSection&); // non-copyable
27
- SequencerDisabledSection (const SequencerDisabledSection&); // non-copyable
28
- const pc::CriticalSection& cs; };
29
-
30
-
31
11
/*
32
12
* ModeX 320x240 initialization
33
13
*
34
14
* This is taken directly from M.Abrash's Mode-X .asm code
35
15
*/
36
16
void SetModeX () {
37
- SetBIOSMode (0x13 );
17
+ bios::SetMode (0x13 );
38
18
SpinUntilNextRetraceBegins ();
39
19
40
20
pc::TXdw (VP_SEQC, 0x604 ); // disable chain4
Original file line number Diff line number Diff line change 2
2
#include < cstdint>
3
3
#include < cstdlib>
4
4
5
+ #include " vga_bios.hpp"
5
6
#include " vga_reg.hpp"
6
7
7
8
using std::uint8_t ;
@@ -10,7 +11,7 @@ using std::uint16_t;
10
11
namespace rqdq {
11
12
namespace vga {
12
13
13
- const int VM_TEXT = 3 ;
14
+ const int VM_TEXT = 0x03 ;
14
15
const int VM_MODE13 = 0x13 ;
15
16
const int VM_MODEX = 0x100 ;
16
17
@@ -26,27 +27,24 @@ const vga::VRAMPage modeXPages[2] = {
26
27
{ 1 , vga::VGAPTR + (320 *240 /4 ), 320 *240 /4 } };
27
28
28
29
29
- void SetBIOSMode (int num);
30
30
void SetModeX ();
31
31
32
32
33
33
class ModeSetter {
34
34
public:
35
- // XXX assume text-mode, need detection
36
- ModeSetter () :oldMode_(0x3 ), curMode_(oldMode_) {}
35
+ ModeSetter ()
36
+ :oldMode_(bios::GetMode()),
37
+ curMode_ (oldMode_) {}
37
38
38
39
void Set (int req) {
39
- if (req == VM_TEXT) {
40
- vga::SetBIOSMode (0x3 );
41
- curMode_ = VM_TEXT; }
42
- else if (req == VM_MODE13) {
43
- vga::SetBIOSMode (0x13 );
44
- curMode_ = VM_MODE13; }
40
+ if (req < 256 ) {
41
+ bios::SetMode (req);
42
+ curMode_ = req; }
45
43
else if (req == VM_MODEX) {
46
44
vga::SetModeX ();
47
45
curMode_ = VM_MODEX; }
48
46
else {
49
- // XXX
47
+ // xxx throw std::runtime_error("unsupported vga mode");
50
48
std::exit (1 ); }}
51
49
52
50
~ModeSetter () {
Original file line number Diff line number Diff line change 5
5
#include < cstdint>
6
6
7
7
#include " pc_bus.hpp"
8
+ #include " pc_cpu.hpp"
8
9
9
10
using std::uint8_t ;
10
11
using std::uint16_t ;
@@ -103,5 +104,17 @@ inline void SpinWhileHorizontalRetrace() {
103
104
*/
104
105
105
106
107
+ class SequencerDisabledSection {
108
+ public:
109
+ SequencerDisabledSection (const pc::CriticalSection& cs) :cs(cs) {
110
+ pc::TXdw (VP_SEQC, 0x100 ); } // clear bit 1, starting reset
111
+ ~SequencerDisabledSection () {
112
+ pc::TXdw (VP_SEQC, 0x300 ); } // undo reset / restart sequencer)
113
+ private:
114
+ SequencerDisabledSection& operator =(const SequencerDisabledSection&); // non-copyable
115
+ SequencerDisabledSection (const SequencerDisabledSection&); // non-copyable
116
+ const class pc ::CriticalSection& cs; };
117
+
118
+
106
119
} // namespace vga
107
120
} // namespace rqdq
You can’t perform that action at this time.
0 commit comments